Advertisement
_gh05tShA40w_

File_Manager: 2.6 (For Linux)

Aug 10th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.39 KB | None | 0 0
  1. #!/usr/bin/python3
  2. #automation script console thing
  3. import os, re
  4. try:
  5. from to_encode_or_to_decode import *
  6. print("Ah nice; imported 'to encode or to decode.py'!")
  7. except ImportError:
  8. print("Sorry, error importing 'to_encode_or_to_decode.py'.")
  9. except IOError:
  10. print("Ok wtf, really sorry; that is truly unexpected!")
  11. try:
  12. from google_graber_ import *
  13. print("Ah nice, imported 'google_graber'.")
  14. except ImportError:
  15. print("Sorry, was unable to import 'google_graber'.")
  16. cmdlist = ["cmdlist:\nList's all available commands with a brief description.",
  17. "exit:\nExits the program.",
  18. "clear:\nClears the current screen.",
  19. "ldir:\nLists all the files in the current directory.",
  20. "ldirperm:\nLists all the files in the current directory; in the longer format, displaying read and write permisions.",
  21. "mkfile:\nPrompts the user for input (@ the '$'). Then makes a file with that name.",
  22. "rmfile:\nPrompts a user for input then removes a file that matches that input.",
  23. "pwd:\nPrints the current working directory.",
  24. "mkdir:\nPrompts the user for a name and makes a directory.",
  25. "rmdir:\nPrompts the user for a name and then removes a directory.",
  26. "chdir:\nPrompts the user to provide a path. e.g. '/home/admin/otherdirectory', then changes the current directory to that path.",
  27. "b64console:\nProvides the user with a console to base64 encode data.",
  28. "printf:\nPrints out the text to the screen e.g 'printf sometext'.",
  29. "read:\nPrints out the content of a file.",
  30. "write:\nWrites input to a file.",
  31. "usr:\nPrints the name of the current user.",
  32. "printl:\nPrints a given argument is a letter by letter format."
  33. "ping:\nTests a network for latency but is a good way to see if your network is reaching the Internet.",
  34. "fullforms:\nPrints out a short list of full names for file extensions. E.g: '.txt', '.gif'.",
  35. "odhc:\nDisplays info about the American Standard Code for Information Interchange(ASCII). character set. It's encoded in octal, decimal, and hexadecimal.",
  36. "digfile:\nPrompts you for a filename and string of text to search. If it finds a match will print out a result. Note: you must be in the right directory.",
  37. "digdir:\nPrompts you for a path to a directory and for content to search for recursively and match. For example: '/home/user/dir' < [path example]",
  38. "findStr:\nAsks for a filename and then searches it for a specific string based on another input.(The file you are searching must be in the same directory)",
  39. "gg:\nOpens the menu for 'google_graber' (used for web crawling/google hacking)."
  40. ]
  41. def BasicSH():
  42. return input("$ ")
  43. def pleasefilename():
  44. print("Please enter a filename at the prompt. ('$')\n")
  45. def pleasedirectoryname():
  46. print("Please enter a directory name at the promt. ('$')\n")
  47. def pleasepath():
  48. print("Please enter a valid path. ( '/home/username/myfiles')\n")
  49. def start():
  50. print("Welcome, we hope this helps better navigate file-systems...")
  51. cwd=os.getcwd(); print("The current directory is:"+cwd+".")
  52. print("For a full list of commands just type 'cmdlist'.\nYour command: ")
  53. cmd=input("$"); return cmd
  54. def init_msg():
  55. print("[+]FileManagerProgram[+]")
  56. def issue_cmd(cmd):
  57. if cmd == "cmdlist":
  58. for each in cmdlist:
  59. print("\n%s"%(each))
  60. elif cmd == "clear":
  61. command_list.clear()
  62. elif cmd == "exit":
  63. exit()
  64. elif cmd == "mkfile":
  65. pleasefilename()
  66. command_list.mkfile(BasicSH())
  67. elif cmd == "rmfile":
  68. pleasefilename()
  69. command_list.rmfile(BasicSH())
  70. elif cmd == "pwd":
  71. command_list.pwd()
  72. elif cmd == "mkdir":
  73. pleasedirectoryname()
  74. command_list.mkdir(BasicSH())
  75. elif cmd == "rmdir":
  76. pleasedirectoryname()
  77. command_list.mkdir(BasicSH())
  78. elif cmd == "chdir":
  79. pleasepath()
  80. command_list.chdir(BasicSH())
  81. elif cmd == "ldir":
  82. command_list.ldir()
  83. elif cmd == "ldirperm":
  84. command_list.ldirperm()
  85. elif cmd == "b64console":
  86. to_encode_or_to_decode()
  87. elif cmd == "printf":
  88. command_list.printf()
  89. elif cmd == "read":
  90. command_list.read()
  91. elif cmd == "write":
  92. command_list.write()
  93. elif cmd == "usr":
  94. command_list.usr()
  95. elif cmd == "printl":
  96. command_list.printl()
  97. elif cmd == "fullforms":
  98. command_list.fullforms()
  99. elif cmd == "odhc":
  100. command_list.odhc()
  101. elif cmd == "digfile":
  102. command_list.digfile()
  103. elif cmd == "digdir":
  104. command_list.digdir()
  105. elif cmd == "findStr":
  106. command_list.findStr()
  107. elif cmd == "gg":
  108. google_graber.menu(1)
  109. #space
  110. class command_list:
  111. def clear():
  112. return os.system("clear")
  113. def ldir():
  114. return os.system("ls -a")
  115. def ldirperm():
  116. return os.system("ls -la")
  117. def mkfile(filename):
  118. try:
  119. os.system("touch %s"%(filename))
  120. except IOError:
  121. print("""Sorry error making the file\n
  122. Already a file with this name in this directory?""")
  123. def rmfile(filename):
  124. return os.remove(filename)
  125. def pwd():
  126. return os.getcwd()
  127. def mkdir(dirname):
  128. return os.mkdir(dirname)
  129. def rmdir(dirname):
  130. return os.rmdir(dirname)
  131. def chdir(path):
  132. return os.chdir(path)
  133. def printf():
  134. print("Please enter some text to be printed: \n")
  135. i=BasicSH(); print("%s"%(i))
  136. def read():
  137. print("Filename to print to screen:\n"); arg=BasicSH()
  138. try:
  139. os.system("cat %s"%(arg))
  140. except IOError:
  141. print("Sorry file not found...")
  142. finally:
  143. print("\n")
  144. def write():
  145. print("filename please:\n"); filename=BasicSH()
  146. print("Content to write to file:\n"); content=BasicSH()
  147. try:
  148. open_file=open("%s"%(filename),"a+"); open_file.write(content)
  149. print("Written to file!")
  150. except FileNotFoundError:
  151. print("Sorry, file not found!\nWrong directory?\nWrong file name?\n")
  152. except IOError:
  153. print("Sorry an error has taken place!")
  154. def usr():
  155. return os.system("echo $USER")
  156. def printl():
  157. print("Content:\n"); arg=BasicSH()
  158. for all in arg:
  159. print(all)
  160. def ping():
  161. return os.system("ping %s"%(BasisSH()))
  162. def fullforms():
  163. info = [
  164. "3GP: 3rd generation Project.",
  165. "3GPP: 3rd generation Partnership Project.",
  166. "ACC: Advanced Audio Coding.",
  167. "AMR: Adaptive Multi-Rate Codec.",
  168. "AVI: Audio video Interleave.",
  169. "BMP: Bitmap.",
  170. "DOC: Document.",
  171. "DVX: DivX Video.",
  172. "GIF: Graphic Interchangeable format.",
  173. "JAD: Java Application Descriptor.",
  174. "JAR: Java Archive.",
  175. "JPEG: Joint Photographic Expert Group.",
  176. "M3G: Mobile 3D Graphics.",
  177. "M4A: MPEG-4 Audio File.",
  178. "MP3: Moving Picture Experts Group PhasePHASE3 (MPEG-3).",
  179. "MP4: MPEG-4 video file.",
  180. "MPEG: Moving Pictures Experts Group.",
  181. "(MPEG) MPEG1: Moving Pictures Experts Group.",
  182. "(MPEG-1)MPEG2: Moving Picture Experts Group.",
  183. "PhasePHASE 2 (MPEG-2).",
  184. "PDF: Portable Document Format.",
  185. "PNG: Portable Network Graphics.",
  186. "RTS: Real Time Streaming.",
  187. "SIS: Symbian OS Installer file.",
  188. ]
  189. for x in info:
  190. print("%s\n"%(x))
  191. def odhc():
  192. os.system("man ascii")
  193. def digfile():
  194. print("Filename: \n"); filename=BasicSH()
  195. print("Search-terms: \n"); searchterms=BasicSH()
  196. os.system("grep -i %s %s"%(searchterms,filename))
  197. def digdir():
  198. print("Directory: \n"); directory=BasicSH()
  199. print("Search-terms: \n"); searchdir=BasicSH()
  200. os.system("grep -R -i %s %s"%(searchdir,directory))
  201. def findStr():
  202. print("Filename please: \n")
  203. filename=BasicSH()
  204. try:
  205. with open("%s"%(filename),"r+") as file:
  206. i=input("String: ")
  207. search = re.compile(r'%s'%(i))
  208. for line in file:
  209. find=search.findall("%s"%(i))
  210. if find == []:
  211. print("Sorry nothing found.")
  212. else:
  213. for each in find:
  214. print("Found: %s"%(each))
  215. except IOError:
  216. print("There was an error in some input or output operation. Could it be the filename?")
  217. finally:
  218. file.close()
  219. def main():
  220. issue_cmd(start())
  221. while 1 == True:
  222. init_msg(); issue_cmd(BasicSH())
  223. if __name__ == "__main__":
  224. main()
  225.  
  226. #The base 64 script 'to_encode_or_to_decode.py'
  227.  
  228. #!/usr/bin/python3
  229. import base64
  230. def sh(arg):
  231. i=input(arg); return i
  232. def encode(arg):
  233. i=base64.b64encode(arg.encode(encoding="utf-8",errors="strict")); print("Encoded message: \n",i)
  234. def decode(arg):
  235. i=base64.b64decode(eval(arg).decode(encoding="utf-8",errors="strict")); print("Decoded message: \n",i)
  236. def to_encode_or_to_decode():
  237. i=sh("(Psst, press shift to Ctrl_C+V)\n'encode' or 'decode': ")
  238. if i == "encode":
  239. return encode(sh("$: "))
  240. elif i == "decode":
  241. return decode(sh("$: "))
  242. def main():
  243. to_encode_or_to_decode()
  244. if __name__ == "__main__":
  245. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement