Sqlmap扩展—外部IP代理池实现

转载自:http://www.lz1y.cn/wordpress/?p=643

 

 

好不容易挖到的注入点,结果总是因为请求速度过快被ban掉ip,我觉得可以给sqlmap加个代理池!暑假前的想法,今天花了一个下午,终于实现了。原来是准备直接改源码的。但是被一个群里的大佬一语点醒,sqlmap有–proxy参数的。我可以代理本地,然后通过中间服务器来代理ip!也就是类似SS的方式。

打包exe下载链接:http://pan.baidu.com/s/1c2J9JiS 密码:9x6g

py脚本形式下载链接:http://pan.baidu.com/s/1eRHT9nG 密码:311e

到时候扔到cmd里面运行就可以了

流程图如下:

 

 

使用方法:使用Python运行脚本,然后sqlmap中命令加入参数–proxy=http://127.0.0.1:9999

脚本同目录下,ips.txt中以

ip:port

的格式放入已验证的多个ip。即可使用sqlmap的代理池拓展脚本。

实现代码如下:

socket Python

Python

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

# -*-coding:utf-8-*-

"""

ayou

"""

importsocket

fromsocketimporterror

importthreading

importrandom

importtime

 

localtime=time.asctime(time.localtime(time.time()))

 

classProxyServerTest():

    def__init__(self,proxyip):

        #本地socket服务

        self.ser=socket.socket(socket.AF_INET,socket.SOCK_STREAM)

        self.proxyip=proxyip

 

    defrun(self):

        try:

            #本地服务IP和端口

            self.ser.bind(('127.0.0.1',9999))

            #最大连接数

            self.ser.listen(5)

        excepterrorase:

            print("[-]The local service : "+str(e))

            return"[-]The local service : "+str(e)

        whileTrue:

            try:

                #接收客户端数据

                client,addr=self.ser.accept()

                print('[*]accept %s connect'%(addr,))

                data=client.recv(1024)

                ifnotdata:

                    break

                print('[*'+localtime+']: Accept data...')

            excepterrorase:

                print("[-]Local receiving client : "+str(e))

                return"[-]Local receiving client : "+str(e)

            whileTrue:

                    #目标代理服务器,将客户端接收数据转发给代理服务器

                    mbsocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)

                    iplen=len(self.proxyip)      

                    proxyip=self.proxyip[random.randint(0,iplen-1)]

                    print("[!]Now proxy ip:"+str(proxyip))

                    prip=proxyip[0]

                    prpo=proxyip[1]

                    try:

                        mbsocket.settimeout(3)

                        mbsocket.connect((prip,prpo))

                    except:

                        print("[-]RE_Connect...")

                        continue

                    break

#                   except :

#                       print("[-]Connect failed,change proxy ip now...")

  #                      pass

            try:    

                mbsocket.send(data)

            excepterrorase:

                print("[-]Sent to the proxy server : "+str(e))

                return"[-]Sent to the proxy server : "+str(e)

            

            whileTrue:

                try:

                    #从代理服务器接收数据,然后转发回客户端

                    data_1=mbsocket.recv(1024)

                    ifnotdata_1:

                        break

                    print('[*'+localtime+']: Send data...')

                    client.send(data_1)

                exceptsocket.timeoutase:

                    print(proxyip)

                    print("[-]Back to the client : "+str(e))

                    continue

            #关闭连接

            client.close()

            mbsocket.close()

 

defLoadips():

    print("[*]Loading proxy ips..")

    ip_list=[]

    ip=['ip','port']

    withopen("ips.txt")asips:

        lines=ips.readlines()

    forlineinlines:

        ip[0],ip[1]=line.strip().split(":")

        ip[1]=eval(ip[1])

        nip=tuple(ip)

        ip_list.append(nip)

    returnip_list

    

defmain():

    print('''*Atuhor : V@1n3R.

*Blog :http://www.Lz1y.cn

*date: 2017.7.17

*http://www.Lz1y.cn/wordpress/?p=643

    

    

    

    

 

                                

                         __     __    _       _____ ____    

                         \ \   / /_ _/ |_ __ |___ /|  _ \  

                          \ \ / / _` | | '_ \  |_ \| |_) |  

                           \ V / (_| | | | | |___) |  _ < _

                            \_/ \__,_|_|_| |_|____/|_| \_(_)

                                    

                                    

                                            

                                            

                                            

                                            

                                            

    ''')

    ip_list=Loadips()    

#   ip_list = [('118.89.148.92',8088)]

#   ip_list = tuple(ip_list)

    try:

        pst=ProxyServerTest(ip_list)

        #多线程

        t=threading.Thread(target=pst.run,name='LoopThread')

        print('[*]Waiting for connection...')

        #关闭多线程

        t.start()

        t.join()

    exceptExceptionase:

        print("[-]main : "+str(e))

        return"[-]main : "+str(e)

 

if__name__=='__main__':

    main()

实现:

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值