web.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /*
  2. This file is part of the cintruder project, https://cintruder.03c8.net
  3. Copyright (c) 2012/2020 psy <epsylon@riseup.net>
  4. cintruder is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation version 3 of the License.
  7. cintruder is distributed in the hope that it will be useful, but WITHOUT ANY
  8. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. details.
  11. You should have received a copy of the GNU General Public License along
  12. with cintruder; if not, write to the Free Software Foundation, Inc., 51
  13. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. */
  15. window.onload = function() {
  16. document.getElementById('ifTrack').style.display = 'block';
  17. document.getElementById('ifTrain').style.display = 'none';
  18. document.getElementById('ifCrack').style.display = 'none';
  19. document.getElementById('ifLocal').style.display = 'block';
  20. document.getElementById('ifUrl').style.display = 'none';
  21. document.getElementById('ifCrackLocal').style.display = 'block';
  22. document.getElementById('ifCrackUrl').style.display = 'none';
  23. document.getElementById('ifMod_set').style.display = 'none';
  24. document.getElementById('ifMod_set_crack').style.display = 'none';
  25. document.getElementById('ifMod_colour').style.display = 'none';
  26. document.getElementById('ifMod_xml').style.display = 'none';
  27. document.getElementById('Results').style.display = 'none';
  28. document.getElementById('Captcha-IN').style.display = 'none';
  29. document.getElementById('OCR-out').style.display = 'none';
  30. }
  31. function SetDefault(){
  32. document.getElementById('track_url').value = '';
  33. document.getElementById('track_num').value = '5';
  34. document.getElementById('tor').checked = false;
  35. document.getElementById('verbose').checked = false;
  36. document.getElementById('SourceFile').value = '';
  37. document.getElementById('train_url').value = '';
  38. document.getElementById('tor2').checked = false;
  39. document.getElementById('verbose2').checked = false;
  40. document.getElementById('set_module').checked = false;
  41. document.getElementById('use_mod').value = '';
  42. document.getElementById('set_colour_id').checked = false;
  43. document.getElementById('set_id').value = '';
  44. document.getElementById('SourceFile2').value = '';
  45. document.getElementById('crack_url').value = '';
  46. document.getElementById('tor3').checked = false;
  47. document.getElementById('set_module_crack').checked = false;
  48. document.getElementById('use_mod_crack').value = '';
  49. document.getElementById('set_xml').checked = false;
  50. document.getElementById('set_xml_file').value = '';
  51. document.getElementById('verbose3').checked = false;
  52. document.getElementById('Results').style.display = 'none';
  53. document.getElementById('Captcha-IN').style.display = 'none';
  54. document.getElementById('OCR-out').style.display = 'none';
  55. document.getElementById('ifMod_set').style.display = 'none';
  56. document.getElementById('ifMod_set_crack').style.display = 'none';
  57. document.getElementById('ifMod_colour').style.display = 'none';
  58. document.getElementById('ifMod_xml').style.display = 'none';
  59. }
  60. function OptionsCheck() {
  61. if (document.getElementById('track').checked) {
  62. document.getElementById('ifTrack').style.display = 'block';
  63. document.getElementById('ifTrain').style.display = 'none';
  64. document.getElementById('ifCrack').style.display = 'none';
  65. SetDefault()
  66. }
  67. else if(document.getElementById('train').checked) {
  68. document.getElementById('ifTrain').style.display = 'block';
  69. document.getElementById('ifTrack').style.display = 'none';
  70. document.getElementById('ifCrack').style.display = 'none';
  71. SetDefault()
  72. TrainSourcesCheck()
  73. }
  74. else if(document.getElementById('crack').checked) {
  75. document.getElementById('ifCrack').style.display = 'block';
  76. document.getElementById('ifTrack').style.display = 'none';
  77. document.getElementById('ifTrain').style.display = 'none';
  78. SetDefault()
  79. CrackingCheck()
  80. }
  81. }
  82. function TrainSourcesCheck() {
  83. if(document.getElementById('training_local').checked) {
  84. document.getElementById('ifLocal').style.display = 'block';
  85. document.getElementById('ifUrl').style.display = 'none';
  86. SetDefault()
  87. SetTrainModule()
  88. }
  89. else if(document.getElementById('training_url').checked) {
  90. document.getElementById('ifUrl').style.display = 'block';
  91. document.getElementById('ifLocal').style.display = 'none';
  92. SetDefault()
  93. SetTrainModule()
  94. }
  95. }
  96. function CrackingCheck() {
  97. if(document.getElementById('cracking_local').checked) {
  98. document.getElementById('ifCrackLocal').style.display = 'block';
  99. document.getElementById('ifCrackUrl').style.display = 'none';
  100. SetDefault()
  101. SetCrackModule()
  102. }
  103. else if(document.getElementById('cracking_url').checked) {
  104. document.getElementById('ifCrackUrl').style.display = 'block';
  105. document.getElementById('ifCrackLocal').style.display = 'none';
  106. SetDefault()
  107. SetCrackModule()
  108. }
  109. }
  110. function SetTrainModule() {
  111. if((document.getElementById('set_module').checked == true)) {
  112. document.getElementById('ifMod_set').style.display = 'block';
  113. document.getElementsByName('train_url')[0].placeholder='Train using a specific OCR exploiting module';
  114. }
  115. else{
  116. document.getElementById("use_mod").value ='';
  117. document.getElementById('ifMod_set').style.display = 'none';
  118. document.getElementsByName('train_url')[0].placeholder='Apply common OCR techniques to a remote captcha';
  119. }
  120. }
  121. function SetColourID() {
  122. if((document.getElementById('set_colour_id').checked == true)) {
  123. document.getElementById('ifMod_colour').style.display = 'block';
  124. }
  125. else{
  126. document.getElementById("set_id").value ='';
  127. document.getElementById('ifMod_colour').style.display = 'none';
  128. }
  129. if((document.getElementById('set_colour_id3').checked == true)) {
  130. document.getElementById('ifMod_colour2').style.display = 'block';
  131. }
  132. else{
  133. document.getElementById("set_id3").value ='';
  134. document.getElementById('ifMod_colour2').style.display = 'none';
  135. }
  136. }
  137. function SetCrackModule() {
  138. if((document.getElementById('set_module_crack').checked == true)) {
  139. document.getElementById('ifMod_set_crack').style.display = 'block';
  140. document.getElementsByName('crack_url')[0].placeholder='Brute force using a specific OCR exploiting module';
  141. }
  142. else if((document.getElementById('set_module_crack').checked == false)) {
  143. document.getElementById('ifMod_set_crack').style.display = 'none';
  144. document.getElementsByName('crack_url')[0].placeholder="Brute force using local dictionary (from: 'dictionary/')";
  145. }
  146. }
  147. function SetXML() {
  148. if((document.getElementById('set_xml').checked == true)) {
  149. document.getElementById('ifMod_xml').style.display = 'block';
  150. }
  151. else{
  152. document.getElementById("set_xml_file").value ='';
  153. document.getElementById('ifMod_xml').style.display = 'none';
  154. }
  155. }
  156. function loadRemoteOCR(train_url){
  157. fromDataURL('images/previews/last-preview.gif', function(enc_img) {
  158. r = "data:image/gif;base64,";
  159. enc_img = enc_img.replace(r, "");
  160. var dec_img = atob(enc_img)
  161. var img_preview = "data:image/gif;base64,"+dec_img
  162. document.getElementById("target_captcha_img_path").src=img_preview;
  163. document.getElementById('Captcha-IN').style.display = 'block';
  164. document.getElementById("directory-words").src = "directory-words";
  165. document.getElementById("OCR-out").style.display = "block";
  166. })
  167. }
  168. function loadRemoteOCRCrack(crack_url){
  169. fromDataURL('images/previews/last-preview.gif', function(enc_img) {
  170. r = "data:image/gif;base64,";
  171. enc_img = enc_img.replace(r, "");
  172. var dec_img = atob(enc_img)
  173. var img_preview = "data:image/gif;base64,"+dec_img
  174. document.getElementById("target_captcha_img_path").src=img_preview;
  175. document.getElementById('Captcha-IN').style.display = 'block';
  176. })
  177. }
  178. function loadOCRCrack(){
  179. fromDataURL('images/previews/last-preview.gif', function(enc_img) {
  180. r = "data:image/gif;base64,";
  181. enc_img = enc_img.replace(r, "");
  182. var dec_img = atob(enc_img)
  183. var img_preview = "data:image/gif;base64,"+dec_img
  184. document.getElementById("target_captcha_img_path").src=img_preview;
  185. document.getElementById('Captcha-IN').style.display = 'block';
  186. })
  187. }
  188. function loadOCR(){
  189. fromDataURL('images/previews/last-preview.gif', function(enc_img) {
  190. r = "data:image/gif;base64,";
  191. enc_img = enc_img.replace(r, "");
  192. var dec_img = atob(enc_img)
  193. var img_preview = "data:image/gif;base64,"+dec_img
  194. document.getElementById("target_captcha_img_path").src=img_preview;
  195. document.getElementById('Captcha-IN').style.display = 'block';
  196. document.getElementById("directory-words").src = "directory-words";
  197. document.getElementById("OCR-out").style.display = "block";
  198. })
  199. }
  200. function TrackCaptchas(){
  201. if(document.getElementById("tor").checked) {
  202. tor="on";
  203. }else{
  204. tor="off";
  205. }
  206. if(document.getElementById("verbose").checked){
  207. verbose="on";
  208. }else{
  209. verbose="off";
  210. }
  211. tracking_source=document.getElementById("track_url").value
  212. tracking_num=document.getElementById("track_num").value
  213. if(tracking_source == "") {
  214. window.alert("You need to enter a valid URL to be tracked!");
  215. return
  216. }else{
  217. params="tracking_source="+escape(tracking_source)+"&tracking_num="+escape(tracking_num)+"&tor="+escape(tor)+"&verbose="+escape(verbose)
  218. runCommandX("cmd_track",params)
  219. document.getElementById("Results").style.display = "block";
  220. }
  221. }
  222. function TrainCaptchas(){
  223. document.getElementById('Captcha-IN').style.display = 'none';
  224. document.getElementById("OCR-out").style.display = "none";
  225. if(document.getElementById("set_colour_id").checked)
  226. {
  227. colourID=document.getElementById("set_id").value;
  228. }else {
  229. colourID="off";
  230. }
  231. if(document.getElementById("set_module").checked)
  232. {
  233. module=document.getElementById("use_mod").value;
  234. }else {
  235. module="off";
  236. }
  237. if(document.getElementById("tor2").checked)
  238. {
  239. tor="on";
  240. }else {
  241. tor="off";
  242. }
  243. if(document.getElementById("verbose2").checked)
  244. {
  245. verbose="on";
  246. }else {
  247. verbose="off";
  248. }
  249. source_file=document.getElementById("SourceFile").value;
  250. train_url=document.getElementById("train_url").value;
  251. if((source_file == "") && (train_url == "")){
  252. window.alert("You need to enter any input!");
  253. return;
  254. }else{
  255. if(source_file==""){
  256. source_file="off"
  257. }
  258. params="train_url="+escape(train_url)+"&source_file="+escape(source_file)+"&colourID="+escape(colourID)+"&module="+escape(module)+"&tor="+escape(tor)+"&verbose="+escape(verbose);
  259. }
  260. runCommandX("cmd_train",params);
  261. if(source_file=="off"){
  262. document.getElementById("Results").style.display = "block";
  263. setTimeout(function() { loadRemoteOCR(train_url) }, 10000);
  264. }else{
  265. document.getElementById("Results").style.display = "block";
  266. setTimeout("loadOCR()", 6000); // delay 6 on local
  267. }
  268. }
  269. function CrackCaptchas(){
  270. document.getElementById('Captcha-IN').style.display = 'none';
  271. document.getElementById("OCR-out").style.display = "none";
  272. if(document.getElementById("set_module_crack").checked)
  273. {
  274. module=document.getElementById("use_mod_crack").value;
  275. }else {
  276. module="off";
  277. }
  278. if(document.getElementById("set_xml").checked)
  279. {
  280. xml=document.getElementById("set_xml_file").value;
  281. }else {
  282. xml="off";
  283. }
  284. if(document.getElementById("tor3").checked)
  285. {
  286. tor="on";
  287. }else {
  288. tor="off";
  289. }
  290. if(document.getElementById("verbose3").checked)
  291. {
  292. verbose="on";
  293. }else {
  294. verbose="off";
  295. }
  296. if(document.getElementById("set_colour_id3").checked)
  297. {
  298. colourID=document.getElementById("set_id3").value;
  299. }else {
  300. colourID="off";
  301. }
  302. source_file=document.getElementById("SourceFile2").value;
  303. crack_url=document.getElementById("crack_url").value;
  304. if((source_file == "") && (crack_url == "")){
  305. window.alert("You need to enter any input!");
  306. return;
  307. }else{
  308. if(source_file==""){
  309. source_file="off"
  310. }
  311. params="crack_url="+escape(crack_url)+"&source_file="+escape(source_file)+"&colourID="+escape(colourID)+"&module="+escape(module)+"&tor="+escape(tor)+"&verbose="+escape(verbose)+"&xml="+escape(xml);
  312. }
  313. runCommandX("cmd_crack",params);
  314. if(source_file=="off"){
  315. document.getElementById("Results").style.display = "block";
  316. setTimeout(function() { loadRemoteOCRCrack(crack_url) }, 10000);
  317. }else{
  318. document.getElementById("Results").style.display = "block";
  319. setTimeout("loadOCRCrack()", 6000); // delay 6 on local
  320. }
  321. }
  322. function showResults() {
  323. document.getElementById("Results").style.display = "block";
  324. document.getElementById('Captcha-IN').style.display = 'none';
  325. document.getElementById('OCR-out').style.display = 'none';
  326. }
  327. function fromDataURL(url, callback) {
  328. var httpRequest = new XMLHttpRequest();
  329. httpRequest.onload = function() {
  330. var fileReader = new FileReader();
  331. fileReader.onloadend = function() {
  332. callback(fileReader.result);
  333. }
  334. fileReader.readAsDataURL(httpRequest.response);
  335. };
  336. httpRequest.open('GET', url);
  337. httpRequest.responseType = 'blob';
  338. httpRequest.send();
  339. }