Login Register




The stories and information posted here are artistic works of fiction and falsehood. Only a fool would take anything posted here as fact.


[HC Offical] SpiderPy - Regular Expression Crawler filter_list
Author
Message
[HC Offical] SpiderPy - Regular Expression Crawler #1
Hello all, I decided to write another tool for HC! This time I came up with SpiderPy. It's a crawler that, when given a target, recursively searches through the website and runs a regex against every page.

Feature List:
- Crawls Websites based on open links
- Can run predefined REGEX (Email, Phone, IP address)
- Can run user defined regex
- Can set time delay between page scraps
- Can create config file to add additional predefined regex

Usage Examples:
Code:
# Scan example.com for emails with a 1 sec delay ./spiderpy -d EMAIL -t 1000 example.com # Scan example.com for custom regex ./spiderpy -r '".*\.pdf' example.com # Show all predefined(and user defined) regex ./spiderpy -p

Source:
Code:
#!/usr/bin/env python import urllib2, re, sys, argparse, signal from time import sleep signal.signal(signal.SIGINT, lambda x,y: sys.exit(0)) print "\033[95m /\\ /\\/ __\\" print " / /_/ / / SpiderPy - A python REGEX crawler" print "/ __ / /___ Made for http://hackcommunity.com by H3R0" print "\\/ /_/\\____/ \033[00m" class Spider(): def __init__(self, host, args): self.host_url = 'http://' + host self.links = ['http://' + host + '/'] self.regex = { 'EMAIL' : '[a-zA-Z0-9_\.-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-\.]+', 'IP' : '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)', 'PHONE' : '[1|\(]?[2-9]\d{2}\)?[-|\.| ]?\d{3}[-|\.| ]?\d{4}', } self.wait = 500 self.method = 'EMAIL' self._set_config() self._set_args(args) self.crawl() def _set_config(self): try: fn = 'spider.conf' f = open(fn, 'r') c = f.read() v = eval(c) self.regex = dict(self.regex.items() + v.items()) f.close() except: print "\033[93mNo config file found.\nPlease create %s to create more predefined patterns.\033[0m" % fn def _set_args(self, args): if args.patterns: print '\033[94mList of REGEX Patterns to look for on each page...\033[00m' for pattern in self.regex: print pattern sys.exit('') if args.timer: wait = int(args.timer) if args.defined: try: self.regex[args.defined.upper()] except: sys.exit('\033[91mNo Such Pattern\033[0m') else: self.method = args.defined.upper() if args.regex: self.regex['CUSTOM_CLI_REGEX'] = args.regex self.method = 'CUSTOM_CLI_REGEX' def _find_links(self, html): ls = re.findall('<a[^>]*href="([^"]*)"', html) for l in ls: i = '' if not l.startswith('http') and not l.startswith('//') and not l.startswith('javascript:'): i = self.host_url + l if l.startswith('/') else self.host_url + '/' + l elif host in l: i = l if i and not i in self.links: self.links.append(i) def _output_find(self, url, results): print "\033[92m%s" % url print results print "\033[0m" def _run_regex(self, html, url): results = re.findall(self.regex[self.method.upper()], html) if len(results): self._output_find(url, results) def crawl(self, n = 0): # Spiders going to spide. url = self.links[n] try: w = urllib2.urlopen(url) html = w.read() info = w.info().getheader('Content-Type') if info.startswith('text') or 'xml' in info: self._find_links(html) self._run_regex(html, url) else: print "\033[93mSkipping file type %s\033[0m" % info except urllib2.HTTPError: #print url print '\033[93mThere was an issue with the url, skipping page.\033[0m' if n < len(self.links) - 1: sleep(self.wait/1000) self.crawl(n + 1) if __name__ == "__main__": parser = argparse.ArgumentParser(prog='SpiderPy') parser.add_argument('-d', '--defined', default='EMAIL', help='Use a preexisting pattern. Use -p for patterns.') parser.add_argument('-r', '--regex', help='Use a custom regular expression pattern.') parser.add_argument('-t', '--timer', help='Time to wait between loading webpages (in milliseconds).') parser.add_argument('-p', '--patterns', help='List out all defined patterns.', action='store_true') parser.add_argument('host', help='The host name of the website to scrap. (e.g. google.com)') args = parser.parse_args() host = args.host spider = Spider(host, args)

Screen Shot:
[Image: xODNQtY.jpg]
(This post was last modified: 07-29-2014, 09:03 PM by zimba.)
[Image: iQ3pcQu.png]
BTC Address: 1DCKgDaWcmc9dxBkhe9qrTQtrQpoFUzXdn

Reply

RE: HC SpiderPy - Regular Expression Crawler #2
Good job... you did this in one night, I am impressed!

Peace
[Image: wvBFmA5.png]

Reply

RE: HC SpiderPy - Regular Expression Crawler #3
SpiderPy vs my AntiScanner script hahah Tongue
[Image: KLGYoXV.png]

Nice tool btw, keep it up!
Fuck You.

Reply

RE: HC SpiderPy - Regular Expression Crawler #4
So this is like an E-mail, Phone Number or IP crawler right?
This is quite an impressive tool, it reminds me of the E-mail collector feature in Metasploit.
Great work mate Smile
[Image: 5R6Js8r.gif]

Reply

RE: HC SpiderPy - Regular Expression Crawler #5
(07-25-2014, 01:05 AM)RootTheSystem Wrote: SpiderPy vs my AntiScanner script hahah Tongue
Nice tool btw, keep it up!

How did your antiscanner script pick up spiderPy? Should I send a user agent, collect cookie, etc? There is also a timer that you can use (See -t in the help)

(07-25-2014, 01:06 AM)XrpmX13 Wrote: So this is like an E-mail, Phone Number or IP crawler right?
This is quite an impressive tool, it reminds me of the E-mail collector feature in Metaspolit.
Great work mate Smile

Yes, yes, and yes you can also add other regular expressions. Those where just three that I though could be useful. And I haven't seen that (Haven't used metapl0it a whole lot.
[Image: iQ3pcQu.png]
BTC Address: 1DCKgDaWcmc9dxBkhe9qrTQtrQpoFUzXdn

Reply

RE: HC SpiderPy - Regular Expression Crawler #6
(07-25-2014, 01:10 AM)h3r0 Wrote: How did your antiscanner script pick up spiderPy? Should I send a user agent, collect cookie, etc? There is also a timer that you can use (See -t in the help)

I'll soon make a tutorial about it :Smile:

EDIT: I made it, http://www.hackcommunity.com/Thread-Tuto...l-Skiddies
Fuck You.

Reply

RE: HC SpiderPy - Regular Expression Crawler #7
@h3r0 i'm downloading python right now to test if it runs properly on windows 7, will post results asap! Smile

It doesn't work :p
It gives me a lot of errors concerning some code before every print you put in there, i assume that's color you're trying to apply? I tried to remove all of it but now i'm stuck with a stupid error i can't wrap my head around, but i'm also unfamiliar to python, so it could be straight forward Wink
I suggest you get a virtualized windows running and debug your code there, since i am of little use concerning python.
(if you want me to help you, feel free to ask though)

Reply

RE: HC SpiderPy - Regular Expression Crawler #8
(07-26-2014, 09:41 AM)Riverclawz Wrote: @h3r0 i'm downloading python right now to test if it runs properly on windows 7, will post results asap! Smile

It doesn't work :p
It gives me a lot of errors concerning some code before every print you put in there, i assume that's color you're trying to apply? I tried to remove all of it but now i'm stuck with a stupid error i can't wrap my head around, but i'm also unfamiliar to python, so it could be straight forward Wink
I suggest you get a virtualized windows running and debug your code there, since i am of little use concerning python.
(if you want me to help you, feel free to ask though)

Could you output your errors/trace? And I might be able to debug it. I'm not SUPER interested in getting this to work on windows but I'm viewing this as a practice, so I might as well do it.
[Image: iQ3pcQu.png]
BTC Address: 1DCKgDaWcmc9dxBkhe9qrTQtrQpoFUzXdn

Reply

RE: HC SpiderPy - Regular Expression Crawler #9
The error print-out:

C:\Python34>python source.py
File "source.py", line 5
print "\033[95m /\\ /\\/ __\\"
^
SyntaxError: invalid syntax

Also if i remove "\033[95m" the error seems to be resolved and the next syntax error is at the next print with something similar to "\033[95m". Are they color codes?
I think if you remove that bit properly (not like my attempt) it should work, cause he doesn't seem to have a problem with the other code.

Reply

RE: HC SpiderPy - Regular Expression Crawler #10
(07-27-2014, 04:53 PM)Riverclawz Wrote: The error print-out:

C:\Python34>python source.py
File "source.py", line 5
print "\033[95m /\\ /\\/ __\\"
^
SyntaxError: invalid syntax

Also if i remove "\033[95m" the error seems to be resolved and the next syntax error is at the next print with something similar to "\033[95m". Are they color codes?
I think if you remove that bit properly (not like my attempt) it should work, cause he doesn't seem to have a problem with the other code.

It was written for python version 2.7, 3.4 changed a lot of syntax so the two versions are in fact incompatible you could modify it to run in 3.4 though
If you need help feel free to PM me
[Image: klfpJD]
Probitcoin
Freebitcoin
BTC clicks
bitcoin wallet:
1FBPAanbs3rJU9BUpobpDJc9hHUaCaC25N

Reply