-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
810b632
commit 5096bf0
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import shutil, os | ||
|
||
for i in range(200): | ||
path= './randomBox'+str(i) | ||
os.mkdir(path) | ||
os.chdir('./'+path) | ||
for j in range(200): | ||
fileName='flag'+str(j)+'.c' | ||
file= open(fileName,'w') | ||
file.write('#include<stdio.h> \n int main(){ \nprintf("this is flag: '+str(j)+' "); \n} ' ) | ||
file.close() | ||
os.chdir('..') | ||
print(os.path.abspath(path)) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os, random | ||
|
||
keys=['this', 'was', 'the', 'correct', 'key', 'but', 'the', 'correct', 'order', 'can', 'be', 'different', | ||
'so', 'better', 'try', 'a', 'bruteforce'] | ||
|
||
selected_folders=[] | ||
for i in range(len(keys)): | ||
selected_folders.append(random.randrange(0,200,1)) | ||
|
||
for i in range(len(selected_folders)): | ||
os.chdir('./randomBox'+str(selected_folders[i])) | ||
selected_file= random.randrange(0,200,1) | ||
fileName='flag'+str(selected_file)+'.c' | ||
file=open(fileName,'a') | ||
file.write('//here\'s one key : '+keys[i]) | ||
file.close() | ||
print('inserted a key in box number:'+str(selected_folders[i])+'\'s file number: '+str(selected_file)) | ||
os.chdir('..') | ||
print('done') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os, hashlib, time | ||
from itertools import permutations | ||
|
||
startTime=time.time() | ||
toMatch='611d6663e938213f9643144650180a8d' | ||
|
||
toCheck="here's one key :" | ||
|
||
found=[] | ||
for i in range(200): | ||
os.chdir('./randomBox'+str(i)) | ||
|
||
for j in range(200): | ||
with open('flag'+str(j)+'.c', 'r') as file: | ||
data= file.readlines() | ||
for line in data: | ||
lineAsList= line.split() | ||
if ':' in lineAsList: | ||
found.append(lineAsList[-1]) | ||
os.chdir('..') | ||
|
||
|
||
print(len(found)) | ||
matched= False | ||
count =0 | ||
for perm in permutations(found): | ||
permStr= ' '.join(perm) | ||
permHash= hashlib.md5(permStr.encode()).hexdigest() | ||
|
||
if toMatch==permHash: | ||
print('matched answer: '+permStr) | ||
matched= True | ||
break | ||
else: | ||
count+=1 | ||
print(count,'perms checked') | ||
|
||
|
||
if not matched: | ||
print('nothing matched, check the code ') | ||
|
||
endTime=time.time() | ||
print(endTime-startTime,'seconds elapsed') |