码迷,mamicode.com
首页 > 编程语言 > 详细

Python目录扫描

时间:2019-10-29 17:07:08      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:status   stat   数据字典   imp   拼接   rip   str   原理   取数据   

一、目录扫描原理: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("请求失败 ! ") 

 

Python目录扫描

标签:status   stat   数据字典   imp   拼接   rip   str   原理   取数据   

原文地址:https://www.cnblogs.com/yingxiongguixing/p/11759764.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!