├── process.py ├── README.md ├── Malicious-Proxy-Scanner.py └── LICENSE /process.py: -------------------------------------------------------------------------------- 1 | #!/bin/python 2 | #This program will automatically go through a file called 'output.txt' searching for injected javascript code. 3 | #For any injected javascript code, it will print out the line containing injected javascript and IP address and 4 | #port for the proxy that injected said javascript. 5 | malicious = [] 6 | ip = [] 7 | with open('output.txt') as f: 8 | input = f.readlines() 9 | for line in input: 10 | line = line.rstrip('\n') 11 | #lastIP = "" 12 | for line in input: 13 | lineT = line.lower() 14 | if "[-]" in line: 15 | lastIP = line 16 | if "+" in line and (("javascript" in line) or ("js" in line)): 17 | ip.append(lastIP) 18 | malicious.append(line) 19 | for index, line in enumerate(malicious): 20 | print ip[index] 21 | print line 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Scanning for Malicious Proxies 2 | 3 | In the past few years, there has been a lot of press about HTTP proxies that transparently modify traffic to inject javascript for malicious purposes. There have been multiple presentations at DEFCON and blackhat about this topic and a variety of ways of exploiting it including: DDOS, credential theft, and even a distributed method of storage. 4 | 5 | Due to this, I decided to write a script to automatically scan proxies for malicious behavior such as: injecting javascript, modifying forms, and editing HTML. 6 | 7 | The first step was to get a list of proxies that are currently up and freely accessible. For this, I used a modified version of Dan McInerney’s Elite Proxy Finder. Originally, this script allowed for automated speed testing and discovery of elite proxies. I modified this script so as to: 8 | 9 | Output all types of proxies, not just elite proxies (since anonymity is not an issue). 10 | Output proxies that support only http. This was done because proxies are not able to modify resources transmitted over SSL, so support for a protocol that I will not be testing is not needed. 11 | Export a list of proxies and their ports 12 | From there, I had a list of approximately 1000 active free proxies. While this is a relatively small number, I decided to move on with the experiment to see if there was any malicious behavior to be observed even in this small sample size. So on to the results! 13 | 14 | In all 1500 proxies, there was no malicious traffic. What I mean by this is that no proxies transparently edited the traffic without making it very clear that one was not reaching the requested website. There was no injection of javascript. There was no modification of forms. Absolutely no interesting modifications. 15 | 16 | Thus the next step is going to be to use masscan to scan the ipv4 address space to look for free proxies, then once again search for malicious behavior. 17 | 18 | The code used for this post will be posted here once I clean it up a little bit. 19 | 20 | Update: I updated the script slightly so as to increase the number of proxies it discovered. With the addition of the updated script, I have discovered a number of malicious proxies that are currently active. 21 | 22 | Here is a list of all proxies detected with errant behavior and a description of their errant behavior. 23 | 24 | ======= 25 | 26 | The proxy server at 27 | 28 | 221.183.16.219:00080 29 | 30 | modifies HTML sent over HTTP to add the following code to every webpage 31 | 32 | 33 | 34 | Sadly, the adfocus.com.cn domain is not currently accessible, so I cannot view the injected javascript. Based off of the URL of the injected javascript, two conclusions can be made. 35 | 36 | It is javascript used to automatically inject ads into websites accessed over HTTP. This seems to be the most obvious solution since the domain is “adfocus.com.cn” and the javascript file is stored in the “adscript” folder and is called “adfocus.js”. This would make sense since it is a free proxy, the owners of the proxy are likely trying to monetize the business. 37 | However, it seems like this might be what we are supposed to think. I say this because the javascript is hosted on the adfocus.com.cn domain, very similar to the legitimate adfocus.com. It might be that the administrators of this proxy are attempting to capture the reputation of adfocus.com so as to prove the legitimate nature of the injected code. This makes me wonder whether this code serves a more malicious purpose. The injected javascript could do anything from exploit the computer to be part of a botnet to be part of a distributed filesystem. 38 | 39 | ======= 40 | 41 | The proxy server at 42 | 43 | 115.239.210.199:80 44 | 45 | automatically strips all HTML comments from the transmitted data. While this does not have any obvious negative effect, it still modifies the transmitted HTML which is an inherently bad thing for any proxy server. 46 | 47 | ======= 48 | 49 | The proxy server at 50 | 51 | 60.194.40.198:8118 52 | 53 | modifies HTML sent over HTTP to add the following code to every webpage 54 | 55 | 56 | 57 | ======= 58 | 59 | The proxy server at 60 | 61 | 122.225.106.35:80 62 | 63 | modifies HTML sent over HTTP to add the following code to every webpage 64 | 65 |
