Skip to content

Commit

Permalink
added random proxy list and static proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
urule99 committed Aug 5, 2010
1 parent a4aab25 commit 23f06aa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -5,6 +5,8 @@ This is Beta release of jsunpack-network (jsunpackn) version 0.3.2c


RELEASE NOTES: RELEASE NOTES:


1) added -p (proxy) and -P (currentproxy) command line arguments (used during active fetching)

Updates 2010-07-02 version 0.3.2c Updates 2010-07-02 version 0.3.2c


1) encrypted PDF handling and various PDF parsing improvements 1) encrypted PDF handling and various PDF parsing improvements
Expand Down
23 changes: 21 additions & 2 deletions jsunpackn.py
Expand Up @@ -24,7 +24,7 @@
from BeautifulSoup import BeautifulSoup from BeautifulSoup import BeautifulSoup
import sys, os, re, time, subprocess, struct import sys, os, re, time, subprocess, struct
import StringIO, string, gzip, signal, urllib2, socket import StringIO, string, gzip, signal, urllib2, socket
import ConfigParser import ConfigParser, random
from optparse import OptionParser from optparse import OptionParser
from hashlib import sha1 from hashlib import sha1


Expand Down Expand Up @@ -886,10 +886,23 @@ def fetch(self,url):
try: try:
hostname,dstport = self.hostname_from_url(url) hostname,dstport = self.hostname_from_url(url)


if self.OPTIONS.proxy and (not self.OPTIONS.currentproxy):
proxies = self.OPTIONS.proxy.split(',')
self.OPTIONS.currentproxy = proxies[random.randint(0,len(proxies)-1)]
if not self.OPTIONS.quiet:
print '[fetch config] random proxy %s' % (self.OPTIONS.currentproxy)

request = urllib2.Request('http://'+url) request = urllib2.Request('http://'+url)
request.add_header('Referer', 'http://'+refer) request.add_header('Referer', 'http://'+refer)
request.add_header('User-Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)') request.add_header('User-Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)')
opener = urllib2.build_opener()
if self.OPTIONS.currentproxy:
if not self.OPTIONS.quiet:
print '[fetch config] currentproxy %s' % (self.OPTIONS.currentproxy)
proxyHandler = urllib2.ProxyHandler({'http': 'http://%s' % (self.OPTIONS.currentproxy) })
opener = urllib2.build_opener(proxyHandler)
else:
opener = urllib2.build_opener()
remote = opener.open(request).read() remote = opener.open(request).read()


if len(remote) > 0: if len(remote) > 0:
Expand Down Expand Up @@ -1169,6 +1182,12 @@ def main():
parser.add_option('-a', '--active', dest='active', parser.add_option('-a', '--active', dest='active',
help='actively fetch URLs (only for use with pcap/file/url as input)', #default=False, help='actively fetch URLs (only for use with pcap/file/url as input)', #default=False,
action='store_true') action='store_true')
parser.add_option('-p', '--proxy', dest='proxy',
help='use a random proxy from this list (comma separated)',
action='store')
parser.add_option('-P', '--currentproxy', dest='currentproxy',
help='use this proxy and ignore proxy list from --proxy',
action='store')
parser.add_option('-q', '--quiet', dest='quiet', parser.add_option('-q', '--quiet', dest='quiet',
help='limited output to stdout', #default=False, help='limited output to stdout', #default=False,
action='store_true') action='store_true')
Expand Down
3 changes: 3 additions & 0 deletions options.config
Expand Up @@ -17,6 +17,9 @@ decoded:./decoded.log
#log_ips:./$CURDATE-files/malicious_ips #log_ips:./$CURDATE-files/malicious_ips
#decoded:./$CURDATE-files/decoded.log #decoded:./$CURDATE-files/decoded.log


#### You can use a randomized proxy list or a currentProxy (ignores randomness)
#proxy:a.b.c.d:8080,e.f.g.h:80
#currentproxy:i.j.k.l:8000


[decoding] [decoding]
#You can also override the default decoding options using the following options #You can also override the default decoding options using the following options
Expand Down

0 comments on commit 23f06aa

Please sign in to comment.