{"id":203,"date":"2015-02-18T16:51:22","date_gmt":"2015-02-18T21:51:22","guid":{"rendered":"http:\/\/dageek247.tk\/wordpress\/?p=203"},"modified":"2021-04-06T03:46:03","modified_gmt":"2021-04-06T03:46:03","slug":"wpa-password-verification-tool","status":"publish","type":"post","link":"https:\/\/dageek247.com\/wordpress\/uncategorized\/wpa-password-verification-tool\/","title":{"rendered":"WPA Password Verification Tool"},"content":{"rendered":"<p>I was going through my computer projects and realised that I never shared this one on my website. It&#8217;s a tool, coded in C++ that checks a text file for WPA\/WPA2 password compatibility. It is most helpful in network security applications \/ pentesting when you have a password list and aren&#8217;t sure just how much of the list is actually a legitimate password.<\/p>\n<p>For example, we have a text file with these contents:<\/p>\n<blockquote><p>Good Password<br \/>\ngood password<\/p>\n<p>Good Password 1234567890<br \/>\ngood password 1234567890<\/p>\n<p>GoodPassword<br \/>\ngoodpassword<\/p>\n<p>BadPass<br \/>\nbadpass<br \/>\nbadpa55<\/p>\n<p>badpas\u2122<br \/>\nBadPas\u2122<br \/>\nB3dPas\u2122<\/p>\n<p>This is a bad password because the character length is way above the maximum limit of 63 characters, and WPA won&#8217;t allow such horrible things to exist in the first place anyways.<\/p><\/blockquote>\n<p>If we run the tool on it, we get these results:<\/p>\n<p><a href=\"http:\/\/dageek247.com\/wordpress\/wp-content\/uploads\/2015\/02\/screen.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-204\" title=\"Screenshot\" src=\"http:\/\/dageek247.com\/wordpress\/wp-content\/uploads\/2015\/02\/screen-300x151.png\" alt=\"A picture of the tool in action\" width=\"300\" height=\"151\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Finally, here is the source code of the project. It should be able to be compiled with just about any compiler on any operating system.<\/p>\n<blockquote><p>#include &lt;iostream&gt;<br \/>\n#include &lt;fstream&gt;<br \/>\n#include &lt;string&gt;<\/p>\n<p>int help(char *argv[]) {<br \/>\nstd::cout &lt;&lt; &#8220;Usage: &#8221; &lt;&lt; argv[0] &lt;&lt; &#8221; &lt;PasswordFile&gt; [Options]&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0Options:&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0\u00a0\u00a0-wpa\u00a0\u00a0Verify password list using WPA Rules (WPA uses same rules as WPA2)&#8221; &lt;&lt; std::endl;<br \/>\n\/\/std::cout &lt;&lt; &#8221;\u00a0\u00a0\u00a0\u00a0-clean\u00a0\u00a0\u00a0\u00a0Automatically delete invalid passwords from file&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0\u00a0\u00a0-goodlist Print all valid passwords&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0\u00a0\u00a0-badlist\u00a0\u00a0Print all invalid passwords&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0Example:&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0\u00a0\u00a0&#8221; &lt;&lt; argv[0] &lt;&lt; &#8221; passwordlist.txt -wpa -badlist&#8221; &lt;&lt; std::endl;<\/p>\n<p>return(1);<br \/>\n}<\/p>\n<p>int does_exist(char *filetouse) {<br \/>\n\/\/first check to see if the cfg file exists<br \/>\nFILE * pFile;<br \/>\nif(pFile = fopen (filetouse,&#8221;r&#8221;)) {<br \/>\n\/\/the file exists<br \/>\nreturn(1);<br \/>\n} else {<br \/>\n\/\/the file doesnt exist<br \/>\nreturn(0);<br \/>\n}<br \/>\n}<\/p>\n<p>int verify(int argc, char *argv[]) {<br \/>\n\/\/variables for later usage<br \/>\n\/\/booleans for user options<br \/>\nbool wpa = false;<br \/>\n\/\/bool clean = false;<br \/>\nbool goodlist = false;<br \/>\nbool badlist = false;<br \/>\n\/\/strings for file reading<br \/>\nstd::string password;<br \/>\nstd::ifstream infile;<br \/>\n\/\/strings for password statistics<br \/>\nint numberoflines = 0;<br \/>\nint numberoftolong = 0;<br \/>\nint numberoftoshort = 0;<br \/>\nint numberofbadchar = 0;<br \/>\nint numberofgood = 0;<br \/>\nint numberofempty = 0;<\/p>\n<p>const char *filetouse = argv[1];<\/p>\n<p>\/\/check all the options<br \/>\nfor (int i = 0; i &lt; argc; i++) {<br \/>\n\/\/options are -wpa -clean -goodlist -badlist<br \/>\nstd::string options[4] = {&#8220;-wpa&#8221;,&#8221;-clean&#8221;,&#8221;-goodlist&#8221;,&#8221;-badlist&#8221;};<br \/>\nif(argv[i] == options[0]) {<br \/>\nwpa = true;<br \/>\n}<br \/>\n\/*if(argv[i] == options[1]) {<br \/>\nclean = true;<br \/>\n}*\/<br \/>\nif(argv[i] == options[2]) {<br \/>\ngoodlist = true;<br \/>\n}<br \/>\nif(argv[i] == options[3]) {<br \/>\nbadlist = true;<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/read the file line by line and check to see if the passwords are right<br \/>\ninfile.open(filetouse); \/\/open the user file<br \/>\nwhile(getline(infile, password)) { \/\/while not the end of the file<br \/>\n\/\/getline(infile,password); \/\/read the current line to std::string password<\/p>\n<p>\/\/count the lines in the password field<br \/>\nnumberoflines += 1;<\/p>\n<p>\/\/check password<br \/>\nif(wpa == true) { \/\/if checking WPA Rules<br \/>\nif(password == &#8220;&#8221;) { \/\/empty line<br \/>\n\/\/skip empty lines<br \/>\nnumberofempty += 1;<br \/>\n} else if(password.size() &gt; 63) {<br \/>\n\/\/password is to big to be used<br \/>\nif(badlist == true) {<br \/>\nstd::cout &lt;&lt; password &lt;&lt; std::endl;<br \/>\n}<br \/>\nnumberoftolong += 1;<br \/>\n} else if(password.size() &lt; 8) {<br \/>\n\/\/password is to small to be used<br \/>\nif(badlist == true) {<br \/>\nstd::cout &lt;&lt; password &lt;&lt; std::endl;<br \/>\n}<br \/>\nnumberoftoshort += 1;<br \/>\n} else if (password.find_first_not_of(&#8220;!\\&#8221;#$%&amp;'()*+,-.\/0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ &#8220;) != std::string::npos) {<br \/>\n\/\/password contains a bad character<br \/>\nif(badlist == true) {<br \/>\nstd::cout &lt;&lt; password &lt;&lt; std::endl;<br \/>\n}<br \/>\nnumberofbadchar += 1;<br \/>\n} else {<br \/>\nif(goodlist == true) {<br \/>\nstd::cout &lt;&lt; password &lt;&lt; std::endl;<br \/>\n}<br \/>\nnumberofgood += 1;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\ninfile.close();<\/p>\n<p>std::cout &lt;&lt; &#8220;Checked &#8221; &lt;&lt; numberoflines &lt;&lt; &#8221; passwords.&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0&#8221; &lt;&lt; numberofempty &lt;&lt; &#8221; lines contained no text&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0&#8221; &lt;&lt; numberoftoshort &lt;&lt; &#8221; lines were to short&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0&#8221; &lt;&lt; numberoftolong &lt;&lt; &#8221; lines were to long&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0&#8221; &lt;&lt; numberofbadchar &lt;&lt; &#8221; lines contained illegal characters&#8221; &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8221;\u00a0\u00a0&#8221; &lt;&lt; numberofgood &lt;&lt; &#8221; lines contained good passwords&#8221; &lt;&lt; std::endl;<\/p>\n<p>return(0);<br \/>\n}<\/p>\n<p>int main(int argc, char *argv[]) {<br \/>\nif(argc &lt;= 1){ \/\/not enough options so help is shown<br \/>\nif(help(argv)) {<br \/>\nstd::cout &lt;&lt; &#8220;Fatal error. Quitting program.&#8221; &lt;&lt; std::endl;<br \/>\nreturn(1);<br \/>\n} \/\/else program is working fine<br \/>\n} else { \/\/plenty of options, better check to see if they are the right ones<br \/>\nif(argv[1] == std::string(&#8220;help&#8221;)) {\/\/display help<br \/>\nif(!help(argv)) {<br \/>\nstd::cout &lt;&lt; &#8220;Fatal error. Quitting program.&#8221; &lt;&lt; std::endl;<br \/>\nreturn(1);<br \/>\n} \/\/else program is working fine<br \/>\n} else {<br \/>\nif(does_exist(argv[1])){<br \/>\nverify(argc, argv);<br \/>\n} else {<br \/>\nstd::cout &lt;&lt; &#8220;Invalid file&#8221; &lt;&lt; std::endl;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n}<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was going through my computer projects and realised that I never shared this one on my website. It&#8217;s a tool, coded in C++ that checks a text file for WPA\/WPA2 password compatibility. It is most helpful in network security applications \/ pentesting when you have a password list and aren&#8217;t sure just how much [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5,7,1,9],"tags":[],"class_list":["post-203","post","type-post","status-publish","format-standard","hentry","category-linux","category-parc","category-tutorial","category-uncategorized","category-windows"],"_links":{"self":[{"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/posts\/203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/comments?post=203"}],"version-history":[{"count":1,"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/posts\/203\/revisions"}],"predecessor-version":[{"id":258,"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/posts\/203\/revisions\/258"}],"wp:attachment":[{"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/media?parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/categories?post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dageek247.com\/wordpress\/wp-json\/wp\/v2\/tags?post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}