18143453325 在线咨询 在线咨询
18143453325 在线咨询
所在位置: 首页 > 营销资讯 > 网站运营 > python登录自己搭建的网站

python登录自己搭建的网站

时间:2022-08-22 14:00:01 | 来源:网站运营

时间:2022-08-22 14:00:01 来源:网站运营

基于前阵子我写的HTTP DoS发生程序,改写了一下,实现登录自己搭建的web渗透测试网站。这个网站叫MYZOO,我读研一时候,老师提供的一个实验网站,用来学习Web安全,一个微型的交易网站,可以实现更新简介,查询,转账操作。

实际上,在我们所谓的黑客看来,就是Get请求,Post请求嘛,基于这个:

login 函数:用来登录,获取cookie和connect句柄
profile 函数:一个POST请求,用来更新数据库中的个人简介
query 函数:一个GET请求,用来向数据库查询个人ZOOBAR信息
以上三个算是核心函数了,虽然实现了登录,访问,查询,退出。但是呢?还是感觉没啥味道!然而,这通常是小白迈向Web安全,走向传奇黑客的必经之路。谁不是这么走过来的呢?

CSRF跨站请求伪造, XSS 跨站脚本攻击,SQL注入攻击,等都是基于对网站有一定的了解,那么怎么就叫对网站有一定的了解呢? 我的回答是:

1.会自己搭建网站
2.会写爬虫访问自己的网站
某些我的读者,私信咨询怎么学习黑客?这个话题太大,我很难回答好。本站现在的学术氛围越来越不友好了,答题就加分,不答题就减分。那么答题质量如何保证呢?越来越水呗。不管是学习黑客,还是学习其他什么专业技能,都需要坚持。很多小白都是脑子一热,找一堆技能树,黑客教学视频,学了一阵子,就学不进去了,自然而然的被黑客圈子拒绝在外。

如果非得说个学习路线:

科班路线:我还是推荐上学时期的网络安全试验课目录,我以前回答过

非科班路线:3年前的看雪论坛,其他几乎都是种韭菜




我个人感觉:关注自己喜欢的领域就好,我喜欢黑客的感觉。

坚持向往,慢慢成长,你一定会是瞩目的黑客。

#dos.pyimport http.clientimport urllib.parseimport timeclass Dos(object): def __init__(self): pass def login(self,sleepTime,servAddr,url): for i in range(1): time.sleep(sleepTime) try: test_data = {'login_username': '1', 'login_password': '1','submit_login':'Log in'} test_data_url_encode = urllib.parse.urlencode(test_data) conn = http.client.HTTPConnection(servAddr) header = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn.request(method="POST", url=url, headers=header, body=test_data_url_encode) response = conn.getresponse() #print(response.status) res_head = response.headers set_cookie = res_head.__dict__['_headers'][7] cookie = set_cookie[1].split(';')[0] #print(cookie) res = response.read() #print(res) #conn.close() except IOError as e: print("except:",e) finally: if i % 10 == 0: print("login ok! /ncookie:",cookie) return conn,cookie def profile(self,conn,sleepTime,your_profile,url,req_head): for i in range(1): time.sleep(sleepTime) try: test_data = {'profile_update': your_profile, 'profile_submit': 'Save'} test_data_url_encode = urllib.parse.urlencode(test_data) header = req_head conn.request(method="POST", url=url, headers=header, body=test_data_url_encode) response = conn.getresponse() res = response.read() except IOError as e: print("except:",e) finally: #print('end profile') pass def query(self,conn,sleepTime,url,req_head): for i in range(1): time.sleep(sleepTime) try: header = req_head conn.request(method="GET", url=url, headers=header) response = conn.getresponse() #print(response.status) res = response.read() #print(res) conn.close() except IOError as e: print("except:",e) finally: #print('end profile') passif __name__ == '__main__': servAddr = "172.28.13.40" url = "/myzoo/" url_profile = '/myzoo/index.php' url_query = '/myzoo/users.php?user=1' cookie = '' referer = '' req_header = { 'Accept': 'text / html, application / xhtml + xml, application / xml;q = 0.9, image / webp, image / apng, * / *;q = 0.8', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh - CN, zh;q = 0.9', 'Connection': 'keep - alive', 'Cookie': cookie, 'Host': '172.28.13.40', 'Referer': referer, 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla / 5.0(WindowsNT6.1;Win64;x64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 67.0.3396.87Safari / 537.36' } sleepTime = 0.01 hack = Dos() dev,cookie = hack.login(sleepTime, servAddr, url) for i in range(100): your_profile = str(i) referer = 'http://172.28.13.40/myzoo/users.php' hack.profile(dev,sleepTime, your_profile, url_profile,req_header) referer = 'http://172.28.13.40/myzoo/index.php' hack.query(dev,sleepTime,url_query,req_header)
74
73
25
news

版权所有© 亿企邦 1997-2022 保留一切法律许可权利。

为了最佳展示效果,本站不支持IE9及以下版本的浏览器,建议您使用谷歌Chrome浏览器。 点击下载Chrome浏览器
关闭