EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra

Knowledge Bank

Discussion Forums
Exploit Database New
PasteBin New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Downloads
Tools

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Pimp Us Out!

Review enigmagroup.org on alexa.com

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.

Enigma Group

Enigma Group

Enigma Group

Enigma Group

 

Affiliates



The Urinal

hackhound.org

suck-o.com

hack.org.za

flyninja.net

 

Enigma Group's Code Bank


Command Console

By: darkside  -  Date Submitted: 2010-03-16 22:36:18

  1. /**
  2.  * Product of Boredom
  3.  * By The Son of Man
  4.  */
  5.  
  6. using System;
  7. using System.Collections.Generic;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11.  
  12. namespace CommandConsole
  13. {
  14. public class Shell
  15. {
  16. public int i = 0;
  17. public static string os, domain, username;
  18.  
  19. public static void interpret(string _cmd)
  20. {
  21. string direct;
  22. int n = 0;
  23.  
  24. switch (_cmd)
  25. {
  26. case "mkdir":
  27. colora();
  28. Console.Write("Directory to create: ");
  29. colorb();
  30. direct = Console.ReadLine();
  31. mkdir(direct);
  32. break;
  33. case "chdir":
  34. colora();
  35. Console.Write("Directory to change to: ");
  36. colorb();
  37. direct = Console.ReadLine();
  38. chdir(direct);
  39. break;
  40. case "cd":
  41. colora();
  42. Console.Write("Directory to change to: ");
  43. colorb();
  44. direct = Console.ReadLine();
  45. chdir(direct);
  46. break;
  47. case "rmdir":
  48. colora();
  49. Console.Write("Directory to remove: ");
  50. colorb();
  51. direct = Console.ReadLine();
  52. rmdir(direct);
  53. break;
  54. case "rndir":
  55. colora();
  56. Console.Write("Directory to rename: ");
  57. colorb();
  58. direct = Console.ReadLine();
  59. rndir(direct);
  60. break;
  61. case "cpdir":
  62. colora();
  63. Console.Write("Directory to copy: ");
  64. colorb();
  65. direct = Console.ReadLine();
  66. cpdir(direct);
  67. break;
  68. case "copy":
  69. copyfile();
  70. break;
  71. case "move":
  72. colora();
  73. Console.Write("Directory of files to move: ");
  74. colorb();
  75. direct = Console.ReadLine();
  76. movefiles(direct);
  77. break;
  78. case "getcwd":
  79. getcwd();
  80. break;
  81. case "cwd":
  82. getcwd();
  83. break;
  84. case "getdrives":
  85. getdrives();
  86. break;
  87. case "drives":
  88. getdrives();
  89. break;
  90. case "exit":
  91. System.Environment.Exit(0);
  92. break;
  93. case "quit":
  94. System.Environment.Exit(0);
  95. break;
  96. case "bye":
  97. System.Environment.Exit(0);
  98. break;
  99. case "clear":
  100. Console.Clear();
  101. break;
  102. case "cls":
  103. Console.Clear();
  104. break;
  105. case "title":
  106. title();
  107. break;
  108. case "help":
  109. help();
  110. break;
  111. case "?":
  112. help();
  113. break;
  114. case "refresh":
  115. Main();
  116. break;
  117. case "restart":
  118. Main();
  119. break;
  120. case "ls":
  121. listdir(n);
  122. break;
  123. case "dir":
  124. listdir(n);
  125. break;
  126. case "setprompt":
  127. setPrompt();
  128. break;
  129. case "prompt":
  130. setPrompt();
  131. break;
  132. default:
  133. colora();
  134. Console.Write("Unknown command: ");
  135. colorb();
  136. Console.Write(_cmd);
  137. break;
  138. }
  139. colora();
  140. }
  141.  
  142. public static void setPrompt()
  143. {
  144. string promptStyle;
  145. Console.Clear();
  146. colora();
  147. Console.Write("New prompt style: ");
  148. colorb();
  149. promptStyle = Console.ReadLine();
  150. customPrompt(promptStyle);
  151. }
  152.  
  153. public static void customPrompt(string promptStyle)
  154. {
  155. string cmd;
  156. do
  157. {
  158. colora();
  159. Console.Write(promptStyle);
  160. colorb();
  161. cmd = Console.ReadLine();
  162. interpret(cmd);
  163. } while (cmd != "exit" || cmd != "EXIT");
  164. }
  165.  
  166. public static void shell()
  167. {
  168. string directory;
  169. string cmd;
  170. chdir("C:\\");
  171.  
  172. do
  173. {
  174. directory = Directory.GetCurrentDirectory();
  175. colora();
  176. Console.Write("[" +username + "@" + domain + "(" + directory + ")]$ ");
  177. colorb();
  178. cmd = Console.ReadLine();
  179. interpret(cmd);
  180. } while (cmd != "exit" || cmd != "EXIT");
  181. }
  182.  
  183. public static void rmdir(string dirName)
  184. {
  185. Directory.Delete(dirName);
  186. }
  187.  
  188. public static void mkdir(string dirName)
  189. {
  190. if (dirName.Equals("\\") || dirName.Equals("/"))
  191. {
  192. colora();
  193. Console.WriteLine("Directory names cannot contain these characters:");
  194. colorb();
  195. Console.WriteLine("\n\n" + "\\\n" + "/\n");
  196. }
  197. else
  198. {
  199. Directory.CreateDirectory(dirName);
  200. colora();
  201. Console.WriteLine("Directory Created");
  202. }
  203. }
  204.  
  205. public static void chdir(string dirName)
  206. {
  207. Directory.SetCurrentDirectory(dirName);
  208. }
  209.  
  210. public static void cpdir(string dirName)
  211. {
  212. colora();
  213. Console.Write("New directory name: ");
  214. colorb();
  215. string targetPath = Console.ReadLine();
  216. System.IO.Directory.CreateDirectory(targetPath);
  217. }
  218.  
  219. public static void rndir(string dirName)
  220. {
  221. string path = dirName;
  222. string target;
  223. colora();
  224. Console.Write("New directory name: ");
  225. colorb();
  226. target = Console.ReadLine();
  227. try
  228. {
  229. if (!Directory.Exists(path))
  230. {
  231. Directory.CreateDirectory(path);
  232. }
  233.  
  234. if (Directory.Exists(target))
  235. {
  236. Directory.Delete(target, true);
  237. }
  238.  
  239. Directory.Move(path, target);
  240. }
  241. catch (Exception e)
  242. {
  243. Console.WriteLine("The process failed: {0}", e.ToString());
  244. }
  245. finally { }
  246. }
  247.  
  248. public static void copyfile()
  249. {
  250. string fileName, sourcePath, targetPath;
  251. colora();
  252. Console.Write("File to copy: ");
  253. colorb();
  254. fileName = Console.ReadLine();
  255. sourcePath = Directory.GetCurrentDirectory();
  256. colora();
  257. Console.Write("Path to copy to: ");
  258. colorb();
  259. targetPath = Console.ReadLine();
  260. string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
  261. string destFile = System.IO.Path.Combine(targetPath, fileName);
  262. System.IO.File.Copy(sourceFile, destFile, true);
  263. }
  264.  
  265. public static void movefiles(string dirName)
  266. {
  267. string sourcePath = dirName, fileName, destFile;
  268. string targetPath;
  269.  
  270. colora();
  271. Console.Write("Directory to move files into: ");
  272. colorb();
  273. targetPath = Console.ReadLine();
  274.  
  275. if (System.IO.Directory.Exists(sourcePath))
  276. {
  277. string[] files = System.IO.Directory.GetFiles(sourcePath);
  278.  
  279. foreach (string s in files)
  280. {
  281. fileName = System.IO.Path.GetFileName(s);
  282. destFile = System.IO.Path.Combine(targetPath, fileName);
  283. System.IO.File.Copy(s, destFile, true);
  284. }
  285. }
  286. }
  287.  
  288. public static void getcwd()
  289. {
  290. string directory = Directory.GetCurrentDirectory();
  291. Console.WriteLine(directory);
  292. }
  293.  
  294. public static void title()
  295. {
  296. string title;
  297. colora();
  298. Console.Write("New title bar text: ");
  299. colorb();
  300. title = Console.ReadLine();
  301. Console.Title = title;
  302. }
  303.  
  304. public static void getdrives()
  305. {
  306. try
  307. {
  308. string[] str = Directory.GetLogicalDrives();
  309. colora();
  310. Console.WriteLine("Available Drive Letters");
  311. colorb();
  312. for (int i = 0; i < str.Length; i++)
  313. {
  314. Console.WriteLine(str[i]);
  315. }
  316. }
  317. catch (IOException e)
  318. {
  319. colorb();
  320. Console.WriteLine(e.ToString());
  321. }
  322. Console.WriteLine();
  323. }
  324.  
  325. public static void help()
  326. {
  327. colora();
  328. Console.WriteLine("CSConsole Help Menu\n");
  329. colorb();
  330. Console.WriteLine("chdir Changes current directory");
  331. Console.WriteLine("clear Clears CSConsole screen");
  332. Console.WriteLine("copy Copies a file");
  333. Console.WriteLine("cpdir Copies a directory");
  334. Console.WriteLine("exit Quits current CSConsole session");
  335. Console.WriteLine("getcwd Displays the current working directory");
  336. Console.WriteLine("getdrives Displays available drive letters");
  337. Console.WriteLine("help Displays this help dialog");
  338. Console.WriteLine("listdir Lists files in a directory");
  339. Console.WriteLine("mkdir Creates a directory");
  340. Console.WriteLine("move Moves files from a directory into another");
  341. Console.WriteLine("refresh Restarts CSConsole");
  342. Console.WriteLine("rmdir Removes a directory");
  343. Console.WriteLine("rndir Renames a directory");
  344. Console.WriteLine("prompt Sets the CSConsole prompt dialog");
  345. Console.WriteLine("title Sets the CSConsole title");
  346. Console.WriteLine();
  347. }
  348.  
  349. public static void listdir(int i)
  350. {
  351. int dirCount = 0;
  352. int fileCount = 0;
  353. Console.WriteLine();
  354. string currentDir = Directory.GetCurrentDirectory();
  355. colora();
  356. Console.WriteLine("Contents of " + currentDir);
  357. Console.WriteLine();
  358.  
  359. string directoryString = Directory.GetCurrentDirectory();
  360. int abc = directoryString.LastIndexOf ('\\');
  361. directoryString = directoryString.Remove (abc, directoryString.Length - abc);
  362. string[] directories = Directory.GetDirectories (directoryString);
  363. colorb();
  364. Console.WriteLine(".\n..");
  365. foreach (string directory in directories)
  366. {
  367. dirCount++;
  368. Console.WriteLine ("{0}", directory);
  369. }
  370.  
  371. DirectoryInfo dirInfo = new DirectoryInfo(currentDir);
  372. FileInfo[] rgFiles = dirInfo.GetFiles();
  373. colorb();
  374. foreach (FileInfo fileInfo in rgFiles)
  375. {
  376. fileCount++;
  377. Console.WriteLine(fileInfo.Name);
  378. }
  379. Console.WriteLine();
  380. if (dirCount != 1)
  381. {
  382. Console.WriteLine(dirCount + " directories and " + fileCount + " file(s) found in this directory.");
  383. }
  384. else if (dirCount == 1)
  385. {
  386. Console.WriteLine(dirCount + " directory and " + fileCount + " file(s) found in this directory.");
  387. }
  388.  
  389. Console.WriteLine();
  390. }
  391.  
  392. public static void setup()
  393. {
  394. Console.Title = "CommandConsole";
  395. domain = System.Environment.UserDomainName.ToString();
  396. os = System.Environment.OSVersion.ToString();
  397. username = System.Environment.UserName.ToString();
  398. colora();
  399. Console.WriteLine(os + "\nCopyright 2010 CommandConsole by Darkside\n\n");
  400. }
  401.  
  402. public static void colora()
  403. {
  404. Console.ForegroundColor = ConsoleColor.Gray;
  405. Console.BackgroundColor = ConsoleColor.Black;
  406. }
  407.  
  408. public static void colorb()
  409. {
  410. Console.ForegroundColor = ConsoleColor.Cyan;
  411. Console.BackgroundColor = ConsoleColor.Black;
  412. }
  413.  
  414. public static void Main()
  415. {
  416. Console.Clear();
  417. setup();
  418. shell();
  419. }
  420. }
  421. }
  422.  
Return to csharp category list

Who Visited EnigmaGroup Today?

1514 Guests, 297 Users (190 Spiders)
memoryshot, mongrel88, drag0n, Kearstin29, litbk, myfabregas, alexelixir, spartanvedicrishi, r0z4, Abhinav2107, theanonymous21, greatg, CreedoFiegree, bivaEmilltite, posthuman01, Taireegaddita, Taicadine, c_a13, hizImmoli, scifics, slchill, KELATALFTUS, kynapse, Tonyui, Hackpad, Epilioptiop, VireekadiaFap, Mamorite, IodindDog, brunoriversyhn, Effomeidonize, ReottphoffBom, arktek, burgeoningneophyte, TradaGreant, SlayingDragons, Waldlyeps, Arsenal, CJ_Omaha, Ryuske, thethird3y3, todayadvila, pwnpwnlolz, NeetaexomYgom, ookami-namikaze, dot_Cipher, Unotohumsmush, SaubymorRoyab, loltyg, Ausome1, Rik, hrangel, cyber-guard, Meonkzt, mori, 31415926, optioniLele, intorerse, FlifobbyFloks, Ios, saraf, Røgue, cossyDrybrich, IvanDimitriev, havisham, KIKNWING, fitz, fleeloCycle, hackboy302, strudels, CootoDorbeeft, gymnediny, hustleman9tv, comando300, Ysri13, thatoneguy, Paran0id, whoami, Pitanteerve, Reapon, cls777, Afrika, suetekh, somebody777, floontiny, Frudopvia, jasonbourne, zombiehack640, CloverCipher, spoosh, Fraubbova, rulebreaker, dncjor, obencefoozy, Fintyoptots, viRuleNt, NipPaineHainy, TheHarrisonW, Jamesgo, TheGanjator, psychomarine, 1421carter, tingle65, claudius, Feld Grau, Partisan, Gunslinger, gydeqqzpn, yshiau, Zaccarato, chromoSone, priovasashCor, ellisp, GothicLogic, keetone, M0rdak, UsedDeteKef, nhorton, archestraty, HatriteBeft, JC06dc5, alpha1, spg, dark_void, wakazi, mtroscheck, TheCheeseDemon, ach.n30, sahariar, hervelegeraf, Psiber_Syn, hackaday, Mod777, neompenly, pollolololo, SnoopSky, Cigmimifs, DrOptix, ProloG-Shaman, unicornrainbow, cheapnikeshoxog, bobsters, foofthoorgo, polemarchos, avacraft, spencerwilliams23, lotato, ryanjcrook, dollerolf, robintenboden, rospark, WexEmbet, BeefSupreme, Hessesian, whydoyoulook, cdpirate, DnA-Ender, CaNcEr, zheincnoob, Vengeance987, justforfun363, RawTeefecycle, Squissesk, aVoid, SaMTHG, neodude, Marion1p, Ops, ddxc, BlAd373, Klosse, khamhou, samsatHD80, PauffPubadvic, AnnaNoult, SexyCreerve, newb1, robster1977, Blizer, Dudleypagrove, Mr_KaLiMaN, FirewallPenetrator, GMo, Seasharp, mrchicken1, Zaxem, N4g4c3N, MaxMeier, Ian, sander.ashwin, Predatorc, lonely.connection, ElEnfermado, wavyd, dirkdanblue, cve916, kalak55, a1los, jell0, Exclaw, veceattainc, Muselele, Mr Pacifist, stylish007, zach, closednetwork99, soroimmuror, PlaneReaction, Wamemanytex38, DieAble, d0seN_36b, jeremy.whitson, lol, nefeolnb, Noticon, statix, anandoump, RomeoG, advilapyday, snorapa, Gkjt, autotuneuser, beanulpinee, 2142, kiklopas, door51, Pizza, deepakkumar, makler2004, M4rcy, Xargos, bdkoenig, Blavatsky, m4f10, Huasca, itsme, xu_lain, Nikhil, ChewBigRed, samxoxo, incicaMaidits, toudioria, Chidokage, Jigoku, cesecyclelm, schn1ffl3r, sam20000, learning, kentora, San Marino, Nightraven, zanydouner, FrofErrodslot, FatalEror, wheaties, akki, AlexDiru, unclejos666, override101, blink_212, uncowstientee, lilkpoigogs, Innonaenupt607, Killshot, ZheIncKnight, ActictGlync, acarseflalk, ___, trashsporn, Memartent, Zoorsornaks, z3z3, heyhey123, Ghajnm, usaliaPels, Ordeptpen, pelly, quellense, Szuba, nmobin27, lamb, x1rt4m, ToutousaRulty, vipervince2002, mannavard1611, BinaryShinigami, Duchdund, afgnumgt, Anatissa, darkfire1515, bennyblanco5000, Mmmett50, ToryLogsEsoff, impalwinona, Kelsfednege, ensubbrut, ant0601
 
Enigma Group