Recreating pattern_create.rb in python!
So, when you don’t have metasploit or ruby in your environment and you need to run pattern_create.rb what do you do?
Well if you’ve got Python available you simply rewrite the code in python.
Here’s the code (it’s used in exactly the same way as the metasploit version of pattern create):
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 | #!/usr/bin/env python # Author: phillips321 # Site: www.phillips321.co.uk # Version 0.1 # Credits: metasploit project # About: Replicates msf pattern_create.rb import sys try:length=int(sys.argv[1]) except:print "[+] Usage: %s <length> [set a] [set b] [set c]" % sys.argv[0]; sys.exit(1) try:seta=sys.argv[2] except:seta="ABCDEFGHIJKLMNOPQRSTUVWXYZ" try:setb=sys.argv[3] except:setb="abcdefghijklmnopqrstuvwxyz" try:setc=sys.argv[4] except:setc="0123456789" string="" ; a=0 ; b=0 ; c=0 while len(string) < length: if len(sys.argv) == 2: string += seta[a] + setb[b] + setc[c] c+=1 if c == len(setc):c=0;b+=1 if b == len(setb):b=0;a+=1 if a == len(seta):a=0 elif len(sys.argv) == 3: print "[!] Error, cannot work with just one set!" print "[+] Usage: %s <length> [set a] [set b] [set c]" % sys.argv[0]; sys.exit(1) sys.exit(1) elif len(sys.argv) == 4: string += seta[a] + setb[b] b+=1 if b == len(setb):b=0;a+=1 if a == len(seta):a=0 elif len(sys.argv) == 5: string += seta[a] + setb[b] + setc[c] c+=1 if c == len(setc):c=0;b+=1 if b == len(setb):b=0;a+=1 if a == len(seta):a=0 else: print "[+] Usage: %s <length> [set a] [set b] [set c]" % sys.argv[0]; sys.exit(1) print "-------------------------------------------------------------------------" print string[:length] print "-------------------------------------------------------------------------" print "Length: %i" % length print "[+] SetA: '%s'" % seta print "[+] SetB: '%s'" % setb if len(sys.argv) != 4: print "[+] SetC: '%s'" % setc print "-------------------------------------------------------------------------" |
From the looks of the pattern_create.rb code in the metasploit library it doesn’t look like I’ve missed functionality. Would be good to know if I have any if anyone finds this useful.
Recent Posts
- Automating an Active Directory Audit in PowerShell
- CherryTree on MacOS (OSX)
- IPv6 LocalLink to IPv4 scanning tool
- NetKit IPv6 Test Lab
- WiPiResponder = Pi Zero W + Responder
- Recovering an activity from a Garmin 920 XT Forerunner
- hashcat on OS X – getting it going!
- PHP NMAP Scan Page
- Hacking the ATN X-sight – part1
- NFSShell on Kali Linux 2.0
Leave a Reply
You must be logged in to post a comment.