본문 바로가기

Research/Source Repository

Python string bruteforce





문자열 브루트포스가 필요할 때, 예를 들어 16진수로 이루어진 4글자의 브루트포스 스트링이 필요하다

라면


import sys

import itertools

choices = '0123456789abcdef'

MaxLength = 4


f = open('res.txt', 'w')

for length in range(0,MaxLength+1):

for entry in itertools.product(choices,repeat = length):

password = '0'*(MaxLength - length) 

password += ''.join(entry)

print password

f.write(password+'\n')


f.close()



이렇게.

혹 앞에 0 패딩을 빼고 싶으면 'password = '0'*(MaxLength - length) ' 문장을 빼고 password 자체로 정의.



result

    1 0000

    2 0000

    3 0001

    4 0002

    5 0003

    6 0004

    7 0005

    8 0006

    9 0007

   10 0008

   11 0009

   12 000a

   13 000b

   14 000c

   15 000d

   16 000e

   17 000f

   18 0000

   19 0001

   20 0002

   21 0003

   22 0004

   23 0005

   24 0006

   25 0007

   26 0008

   27 0009

   28 000a

   29 000b

   30 000c

   31 000d

   32 000e

   33 000f

   34 0010

   35 0011

       ....

69866 ffd8

69867 ffd9

69868 ffda

69869 ffdb

69870 ffdc

69871 ffdd

69872 ffde

69873 ffdf

69874 ffe0

69875 ffe1

69876 ffe2

69877 ffe3

69878 ffe4

69879 ffe5

69880 ffe6

69881 ffe7

69882 ffe8

69883 ffe9

69884 ffea

69885 ffeb

69886 ffec

69887 ffed

69888 ffee

69889 ffef

69890 fff0

69891 fff1

69892 fff2

69893 fff3

69894 fff4

69895 fff5

69896 fff6

69897 fff7

69898 fff8

69899 fff9

69900 fffa

69901 fffb

69902 fffc

69903 fffd

69904 fffe

69905 ffff


'Research > Source Repository' 카테고리의 다른 글

[C#] array byte to hex string  (0) 2014.06.18
Variadic 매크로  (0) 2014.06.16
ThreadPool simple example  (0) 2013.11.03
Mutex - Event Simple Code  (0) 2013.10.10
simple critical section  (0) 2013.10.09