Guest User

Untitled

a guest
Jan 12th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. // desmain.cpp
  2.  
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6.  
  7. int main(int argc, char* argv[])
  8. {
  9. system(argv[1]);
  10.  
  11. std::cout << "Loading " << argv[1] << " into memory..." << std::endl;
  12. std::ifstream* scrambleList = new std::ifstream(argv[1]);
  13. std::ofstream* outputList = new std::ofstream(argv[3]);
  14. std::string scrambleArray[50];
  15. std::string tempStr;
  16. std::string tempStr2;
  17.  
  18. // Loading all the data from the scrambled list into main.
  19. for(int i = 0; i < 50; i++)
  20. {
  21. *scrambleList >> scrambleArray[i];
  22. std::cout << "#" << i << ": " << scrambleArray[i] << std::endl;
  23. if(scrambleList->eof())
  24. break;
  25. }
  26. std::cout << "Loading complete!" << std::endl << std::endl;
  27.  
  28. // Parse and read data from and to other programs
  29. for(int i = 0; scrambleArray[i] != "\0"; i++)
  30. {
  31. std::cout << std::endl << "Executing decoders for " << scrambleArray[i] << std::endl;
  32. tempStr = "deslen ";
  33. tempStr += scrambleArray[i] + " ";
  34. tempStr += argv[2];
  35. tempStr += " ";
  36. tempStr += "temp";
  37. system((char*)tempStr.c_str());
  38.  
  39. std::ifstream* tempList = new std::ifstream("temp");
  40. *tempList >> tempStr2;
  41. tempList->close();
  42. *outputList << tempStr2 << ",";
  43. }
  44.  
  45. scrambleList->close();
  46. outputList->close();
  47.  
  48. system(argv[3]);
  49. return 0;
  50. }
  51.  
  52. // deslen.cpp
  53.  
  54. #include <iostream>
  55. #include <fstream>
  56.  
  57. bool sizeEqual(std::string a,std::string b)
  58. {
  59. int lA = 0;
  60. for(;; lA++)
  61. {
  62. if(a[lA] == '\0')
  63. break;
  64. }
  65. int lB = 0;
  66. for(;; lB++)
  67. {
  68. if(b[lB] == '\0')
  69. break;
  70. }
  71. return (lA == lB);
  72. }
  73.  
  74. int main(int argc, char* argv[])
  75. {
  76. std::ofstream* targetList = new std::ofstream(argv[3]);
  77. std::ifstream* wordList = new std::ifstream(argv[2]);
  78. std::string fullArray[2048];
  79. std::string pos1Array[2048];
  80. std::string pos2Array[2048];
  81. std::string posT1Array[2048];
  82. std::string posT2Array[2048];
  83. int pos = 0;
  84. int test = 0;
  85. int pos2 = 0;
  86. size_t found;
  87.  
  88. // Loading all the data from the full list into the array.
  89. for(int i = 0; i < 2048; i++)
  90. {
  91. *wordList >> fullArray[i];
  92. if(wordList->eof())
  93. break;
  94. }
  95.  
  96. // Remove lines that do not match the size of the answer
  97. pos = 0;
  98. for(int i = 0; fullArray[i] != "\0"; i++)
  99. {
  100. if(sizeEqual(fullArray[i], argv[1]))
  101. {
  102. pos1Array[pos] = fullArray[i];
  103. pos2Array[pos] = fullArray[i];
  104. pos++;
  105. }
  106. }
  107. std::cout << "Calculation round #1 returned " << pos << " combinations." << std::endl;
  108.  
  109. // Remove lines that do not contain the right letters
  110. for(int i = 0; argv[1][i] != '\0'; i++)
  111. {
  112. pos = 0;
  113. for(int x = 0; pos1Array[x] != "\0"; x++)
  114. {
  115. found = pos1Array[x].find(argv[1][i]);
  116. if (found != std::string::npos)
  117. {
  118. pos1Array[x][(int)found] = ' ';
  119. posT1Array[pos] = pos1Array[x];
  120. posT2Array[pos] = pos2Array[x];
  121. pos++;
  122. }
  123. }
  124. pos2 = 0;
  125. for(int x = 0; posT1Array[x] != "\0"; x++)
  126. {
  127. pos1Array[x] = posT1Array[x];
  128. posT1Array[x] = "\0";
  129. pos2Array[x] = posT2Array[x];
  130. posT2Array[x] = "\0";
  131. pos2++;
  132. }
  133. pos1Array[pos2+1] = "\0";
  134. test++;
  135. }
  136. std::cout << "Calculation round #2 returned " << pos << " combinations." << std::endl;
  137. std::cout << test << " calculation rounds where executed." << std::endl;
  138. *targetList << pos2Array[0];
  139.  
  140. wordList->close();
  141. targetList->close();
  142.  
  143. return 0;
  144. }
  145.  
  146. =.> runme.bat <.=
  147.  
  148. desmain scramblelist.txt wordlist.txt targetlist.txt
Add Comment
Please, Sign In to add comment