Hack Forums
Complete Challenge: Folder Hacking - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45)
+--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449)
+---- Forum: Beginner Hacking (https://hackforums.net/forumdisplay.php?fid=4)
+---- Thread: Complete Challenge: Folder Hacking (/showthread.php?tid=5636921)



Complete Challenge: Folder Hacking - mrwhitecock - Jun 1, 2017

In your system, what's the fastest way to make a folder for each alphabet and inside each of these folders there's a subfolder with every alphabet once again.

Alphabets A-Z

Who will win this?


* - Reece Morgan - Jun 1, 2017

Code
for l in {A...Z} do mkdir $l; done
for l in {A...Z} do for i in {A...Z} do mkdir $l/$i; done

Or if you want a one-line solution:
Code
for l in {A...Z} do mkdir $l | for i in {A...Z} do mkdir $/$i; done; done

Note: This is just logic code.


* - Nomad.Null - Jun 1, 2017

I do not dare test this for fear it will recurse forever and completely fuck my SSD. Play with this at your own risk.

PHP Code

<?php 
#!/usr/bin/python

import os
import sys

if sys.argv < 2:
   print(
"[-] You forgot to give me the path to the rabbit hole.")
   return -
1

path 
= sys.argv[1].encode('unicode-escape')
alphabet = "abcdefghijklmnopqrstuvwxyz"

def white_rabbit():
     
   for 
letter in alphabet:
      
os.makedirs('letter')

   for 
root, directories in os.walk(path):
      for 
directory in directories:
         print(
"[+] Now writing to: " + os.path.join(root, directory))
         for 
letter in alphabet:
            
newpath = path + '//' + letter
            os
.chdir(newpath)

            for 
letter in alphabet:
               
os.makedirs('letter')

def main():
   print(
"[*] Welcome, Alice, this is the rabbit-hole to Wonderland.")

   try:
      
os.chdir(path)

   
except OSError:
      print(
"[-] The rabbit hole caved in...\n[-] Your path is broken, fix it.")
      
sys.exit(-1)

   
white_rabbit()

if 
__name__ == '__main__':
   
main() 



* - mrwhitecock - Jun 2, 2017

(Jun 1, 2017 12:42 PM)True Demon Wrote:  I do not dare test this for fear it will recurse forever and completely fuck my SSD. Play with this at your own risk.

PHP Code

<?php 
#!/usr/bin/python

import os
import sys

if sys.argv < 2:
   print(
"[-] You forgot to give me the path to the rabbit hole.")
   return -
1

path 
= sys.argv[1].encode('unicode-escape')
alphabet = "abcdefghijklmnopqrstuvwxyz"

def white_rabbit():
     
   for 
letter in alphabet:
      
os.makedirs('letter')

   for 
root, directories in os.walk(path):
      for 
directory in directories:
         print(
"[+] Now writing to: " + os.path.join(root, directory))
         for 
letter in alphabet:
            
newpath = path + '//' + letter
            os
.chdir(newpath)

            for 
letter in alphabet:
               
os.makedirs('letter')

def main():
   print(
"[*] Welcome, Alice, this is the rabbit-hole to Wonderland.")

   try:
      
os.chdir(path)

   
except OSError:
      print(
"[-] The rabbit hole caved in...\n[-] Your path is broken, fix it.")
      
sys.exit(-1)

   
white_rabbit()

if 
__name__ == '__main__':
   
main() 

Doesn't work. Maybe I do contest winner wins money :D


* - -Mr Mesmer - Jun 2, 2017

(Jun 2, 2017 10:58 AM)mrwhitecock Wrote:  Doesn't work. Maybe I do contest winner wins money :D

Why not take the opportunity to learn to code for yourself?

You'd be expanding on what you already know and could release what you've learned in a tutorial to further help the community.


* - Reece Morgan - Jun 2, 2017

(Jun 2, 2017 10:58 AM)mrwhitecock Wrote:  Doesn't work. Maybe I do contest winner wins money :D

I posted the fucking code in the first post you dumb cunt.
My code works fine.

Why u reply to TrueDemon and not me? I'm not good enough for u because i don't have a fancy sig?

[Image: e9bde3f494aca6d77c51b617a8841ffa.png]

Code
reece@RMorgan-Desktop:~/testfolder$ for l in {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}; do mkdir $l; for i in {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z} ; do  mkdir $l/$i; done; done;
reece@RMorgan-Desktop:~/testfolder$ ls
A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
reece@RMorgan-Desktop:~/testfolder$ ls A
A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
reece@RMorgan-Desktop:~/testfolder$ ls B
A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
reece@RMorgan-Desktop:~/testfolder$

EDIT: Sorry for raging at u im drunked.


* - Nomad.Null - Jun 3, 2017

Reece's code is vastly more efficient than my solution anyhow, and it doesn't result in an infinite recursion. I was under the impression he was looking for a rabbit virus.


* - Condorr - Jun 4, 2017

I remember a .bat file back in the day that was easy to write in notepad and when ran it endlessly makes folders in folders and fucks your HDD. Now im thinking about getting one of those rubber duckies.


* - Alone. - Jun 5, 2017

What will the winner Get?


* - Hello Buddy - Jun 5, 2017

Give this a go. Be careful as it will run forever
PHP Code

<?php 
import os
import string

folders_to_visit 
= ["."]

while 
True:
    for 
x in string.ascii_lowercase:
        
os.mkdir(os.path.join(folers_to_visit[0], x))

        
folders_to_visit.append(os.path.join(folders_to_visit[0], x))

    
folders_to_visit.pop(0)