static void Main(string[] args) { if (args.Length == 2) { // SCRIPT RUN if (args[0].ToUpper() == "-S") { if (File.Exists(args[1])) { string program = File.ReadAllText(args[1]); Directory.SetCurrentDirectory(new FileInfo(args[1]).DirectoryName); CaptchaInterpreter run = new CaptchaInterpreter(program); run.Execute(); } else { Console.WriteLine("The file you specified does not exist!"); Console.ReadKey(); } } } else if (args.Length == 3) { // SCRIPT RUN - Training Mode if (args[0].ToUpper() == "-S" && args[2].ToUpper() == "-T") { if (File.Exists(args[1])) { string program = File.ReadAllText(args[1]); Directory.SetCurrentDirectory(new FileInfo(args[1]).DirectoryName); CaptchaInterpreter run = new CaptchaInterpreter(program, true); run.Execute(); } else { Console.WriteLine("The file you specified does not exist!"); try { Console.Read(); } catch { Console.ReadKey(); } } } } else if (args.Length == 4) { // SCRIPT RUN - WITH IMAGE if (args[0].ToUpper() == "-S" && args[2].ToUpper() == "-I") { if (File.Exists(args[1])) { if (File.Exists(args[3])) { string program = File.ReadAllText(args[1]); Directory.SetCurrentDirectory(new FileInfo(args[1]).DirectoryName); CaptchaInterpreter run = new CaptchaInterpreter(program, new Bitmap(args[3])); run.Execute(); } else { Console.WriteLine("The image you specified does not exist!"); Console.ReadKey(); } } else { Console.WriteLine("The file you specified does not exist!"); try { Console.Read(); } catch { Console.ReadKey(); } } } } else { Console.WriteLine("CAPTCHA Breaking Scripting Language Interpreter"); Console.WriteLine("https" + "://github.com/skotz/captcha-breaking-library"); Console.WriteLine(); Console.WriteLine("Usage:"); Console.WriteLine(" Execute a script:"); Console.WriteLine(" cbli.exe -s <scriptFile.captcha>"); Console.WriteLine(" Execute a script in training mode:"); Console.WriteLine(" cbli.exe -s <scriptFile.captcha> -t"); Console.WriteLine(" Execute a script and pass an image to solve:"); Console.WriteLine(" cbli.exe -s <scriptFile.captcha> -i <imageToSolve.bmp>"); Console.WriteLine(); Console.ReadKey(); } }
static void Main(string[] args) { if (args.Length == 2) { // SCRIPT RUN if (args[0].ToUpper() == "-S") { if (File.Exists(args[1])) { string program = File.ReadAllText(args[1]); Directory.SetCurrentDirectory(new FileInfo(args[1]).DirectoryName); CaptchaInterpreter run = new CaptchaInterpreter(program); run.Execute(); } else { Console.WriteLine("The file you specified does not exist!"); Console.ReadKey(); } } //// COMPILE //else if (args[0].ToUpper() == "-C") //{ // if (File.Exists(args[1])) // { // string program = File.ReadAllText(args[1]); // if (program.ToUpper().Contains("%IMAGE%")) // { // byte[] code = CompileScript(program); // } // else // { // Console.WriteLine("Compiled CAPTCHA Breaker scripts must contain a \"Solve, %IMAGE%\" command."); // Console.ReadKey(); // } // } // else // { // Console.WriteLine("The file you specified does not exist!"); // Console.ReadKey(); // } //} } else if (args.Length == 4) { // SCRIPT RUN - WITH IMAGE if (args[0].ToUpper() == "-S" && args[2].ToUpper() == "-I") { if (File.Exists(args[1])) { if (File.Exists(args[3])) { string program = File.ReadAllText(args[1]); Directory.SetCurrentDirectory(new FileInfo(args[1]).DirectoryName); CaptchaInterpreter run = new CaptchaInterpreter(program, new Bitmap(args[3])); run.Execute(); } else { Console.WriteLine("The image you specified does not exist!"); Console.ReadKey(); } } else { Console.WriteLine("The file you specified does not exist!"); try { Console.Read(); } catch { Console.ReadKey(); } } } } else { Console.WriteLine("You must specify a captcha breaking script to run!"); Console.ReadKey(); } }
void worker_DoWork(object sender, DoWorkEventArgs e) { StartArgs go = (StartArgs)e.Argument; CaptchaInterpreter run = new CaptchaInterpreter(go.Program, go.Image); e.Result = run.Execute(); }
void worker_DoWork(object sender, DoWorkEventArgs e) { try { StartArgs go = (StartArgs)e.Argument; CaptchaInterpreter run = new CaptchaInterpreter(go.Program, go.Image); e.Result = run.Execute(); } catch (Exception ex) { e.Result = ex.Message; } }