一、目录扫描原理:1、读取数据字典文件,拼接url
2、http get请求url
3、判断状态码,输出存在的目录
二、文件读写:
f = open("test.txt","r")
#读取所有
for i in f.readlines():
#取出空行
print(i.strip())
f.close()
#其他写法
with open("test.txt","r") as f:
for i in f.readlines():
print(i.strip())
#读取一行
f = open("test.txt","r")
line = f.readline()
print(line)
f.close()
三、案例拼接url遍历端口扫描:
import requests
import sys
url = sys.argvs
with open("t.txt","r") as f:
for line in f.readlines():
print(line.strip())
r = requests.get(url + ":" + line)
if r.status_code == 200:
print("请求成功 ! ")
else:
print("请求失败 ! ")