]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
made tools/findbits.py importable as a Python module
authordn337t@gmail.com <dn337t@gmail.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Wed, 20 Jun 2012 15:07:30 +0000 (15:07 +0000)
committerdn337t@gmail.com <dn337t@gmail.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Wed, 20 Jun 2012 15:07:30 +0000 (15:07 +0000)
tools/findbits.py

index f5d2dbd6b465c8afb859dac876ed23614525c421..03e0c4e08345f4818c1884a589dd761e5574495e 100755 (executable)
@@ -75,39 +75,43 @@ def domatch(number,binary):
        print '    Reverse: (%s)' % reversed,
        search(inverted,reversed)
 
-if(len(sys.argv) < 3):
-       print
-       print '\t'+sys.argv[0] + ' - Search bitstream for a known number'
-       print
-       print 'Usage: ' + sys.argv[0] + ' <NUMBER> <BITSTREAM>'
-       print
-       print '\tNUMBER will be converted to it\'s BINARY equivalent for all valid'
-       print '\tinstances of BINARY, OCTAL, DECIMAL and HEX, and the bitstream'
-       print '\tand it\'s inverse will be searched for a pattern match. Note that'
-       print '\tNUMBER must be specified in BINARY to match leading zeros.'
-       print
-       print 'Example:'
-       print
-       print '\tfindbits.py 73 0110010101110011'
-       print
-       os._exit(True)
+def main():
+       if(len(sys.argv) < 3):
+               print
+               print '\t'+sys.argv[0] + ' - Search bitstream for a known number'
+               print
+               print 'Usage: ' + sys.argv[0] + ' <NUMBER> <BITSTREAM>'
+               print
+               print '\tNUMBER will be converted to it\'s BINARY equivalent for all valid'
+               print '\tinstances of BINARY, OCTAL, DECIMAL and HEX, and the bitstream'
+               print '\tand it\'s inverse will be searched for a pattern match. Note that'
+               print '\tNUMBER must be specified in BINARY to match leading zeros.'
+               print
+               print 'Example:'
+               print
+               print '\tfindbits.py 73 0110010101110011'
+               print
+               os._exit(True)
 
-bases= { 
-       2:'BINARY',
-       8:'OCTAL',
-       10:'DECIMAL',
-       16:'HEX',
-               }
+       bases=  { 
+               2:'BINARY',
+               8:'OCTAL',
+               10:'DECIMAL',
+               16:'HEX',
+                       }
 
-for base in 2,8,10,16:
-       try:
-               number= int(sys.argv[1],base)
-               print
-               print 'Trying', bases[base]
-               # do BINARY as specified to preserve leading zeros
-               if base == 2:
-                       domatch(sys.argv[1],sys.argv[2])
-               else:
-                       domatch(binstring(number),sys.argv[2])
-       except:
-               continue
+       for base in 2,8,10,16:
+               try:
+                       number= int(sys.argv[1],base)
+                       print
+                       print 'Trying', bases[base]
+                       # do BINARY as specified to preserve leading zeros
+                       if base == 2:
+                               domatch(sys.argv[1],sys.argv[2])
+                       else:
+                               domatch(binstring(number),sys.argv[2])
+               except:
+                       continue
+
+if __name__ == '__main__':
+       main()
Impressum, Datenschutz