Advertisement
Guest User

Untitled

a guest
Feb 27th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public static String Login(String usr, char[] pwd) throws Exception {
  2. InetAddress ip = InetAddress.getLocalHost();
  3. NetworkInterface network = NetworkInterface.getByInetAddress(ip);
  4. byte[] mac = network.getHardwareAddress();
  5. StringBuilder sb = new StringBuilder();
  6. for (int i = 0; i < mac.length; i++) {
  7. sb.append(String.format("%02x%s", mac[i], (i < mac.length - 1) ? ":" : ""));
  8. }
  9. mac_address = sb.toString();
  10. String urlencode_pwd = URLEncoder.encode(pwdEncode(String.valueOf(pwd)), "utf-8");
  11. String data =
  12. "action=login&username="
  13. + usrEncode(usr)
  14. + "&password="
  15. + urlencode_pwd
  16. + "&drop=0&pop=1&type=2&n=117&mbytes=0&minutes=0&ac_id=1&mac="
  17. + mac_address;
  18. String response = HttpPost("http://172.16.154.130:69/cgi-bin/srun_portal", data);
  19. if (response.contains("login_ok")) {
  20. isLinked = true;
  21. return "success";
  22. } else {
  23. isLinked = false;
  24. return response;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement