mirror of
https://github.com/moparisthebest/PagePlusBalance
synced 2024-10-31 15:45:01 -04:00
Fix parsing of page plus's new website, ready pom files for easy market release
This commit is contained in:
parent
f06bb6f68d
commit
93174acade
19
README.md
19
README.md
@ -1,10 +1,25 @@
|
|||||||
PagePlusBalance v0.3
|
PagePlusBalance v0.4
|
||||||
===========================
|
===========================
|
||||||
PagePlusBalance retrieves your balance from PagePlusCellular.com, currently for android phones.
|
PagePlusBalance retrieves your balance from PagePlusCellular.com, currently for android phones.
|
||||||
|
|
||||||
Author: Travis Burtrum (moparisthebest)
|
Author: Travis Burtrum (moparisthebest)
|
||||||
Email: android@moparisthebest.org
|
Email: android@moparisthebest.org
|
||||||
|
|
||||||
|
Features:
|
||||||
|
----------------------
|
||||||
|
1. Gets your balance directly from PagePlusCellular.com,
|
||||||
|
saving bandwidth by making fewer requests than a browser
|
||||||
|
could and not downloading any javascript, css, or images
|
||||||
|
that a browser would.
|
||||||
|
2. Optionally, over mobile data, will send your details
|
||||||
|
to a service on my server that uses the same code to grab
|
||||||
|
your balance from Page Plus as the android app and sending
|
||||||
|
you back only the data you want as plain text, saving you
|
||||||
|
a substantial amount of bandwidth.
|
||||||
|
3. Stores your balance on your phone along with the last
|
||||||
|
time you refreshed it.
|
||||||
|
4. Open source under GNU/AGPL!
|
||||||
|
|
||||||
How to comply with License:
|
How to comply with License:
|
||||||
----------------------
|
----------------------
|
||||||
Basically, the AGPL requires that if you distribute the code,
|
Basically, the AGPL requires that if you distribute the code,
|
||||||
@ -36,4 +51,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
----------------------
|
----------------------
|
||||||
1. Update for new PagePlusCellular.com website that broke parser.
|
1. You suggest it, via a github issue or email!
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.moparisthebest.pageplus"
|
package="org.moparisthebest.pageplus"
|
||||||
android:versionName="0.3" android:versionCode="4">
|
android:versionName="0.4" android:versionCode="5">
|
||||||
<application android:label="@string/app_name" android:icon="@drawable/icon">
|
<application android:label="@string/app_name" android:icon="@drawable/icon">
|
||||||
<activity android:name=".Main"
|
<activity android:name=".Main"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
BIN
android/market/512x512.jpg
Normal file
BIN
android/market/512x512.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
4
android/market/convert.sh
Executable file
4
android/market/convert.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
convert -resize 512x512\! ./orig/orig-owl.jpg 512x512.jpg
|
||||||
|
convert -resize 480x854\! ./orig/ss1.png ss1.png
|
||||||
|
convert -resize 480x854\! ./orig/ss2.png ss2.png
|
BIN
android/market/orig/orig-owl.jpg
Executable file
BIN
android/market/orig/orig-owl.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
android/market/orig/ss1.png
Normal file
BIN
android/market/orig/ss1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
BIN
android/market/orig/ss2.png
Normal file
BIN
android/market/orig/ss2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
BIN
android/market/ss1.png
Normal file
BIN
android/market/ss1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
BIN
android/market/ss2.png
Normal file
BIN
android/market/ss2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 87 KiB |
@ -48,4 +48,25 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>release</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>sign.keystore</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<proguard.skip>false</proguard.skip>
|
||||||
|
</properties>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jarsigner-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
</project>
|
</project>
|
||||||
|
63
android/proguard.cfg
Normal file
63
android/proguard.cfg
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
-dontobfuscate
|
||||||
|
-optimizationpasses 5
|
||||||
|
-dontusemixedcaseclassnames
|
||||||
|
-dontskipnonpubliclibraryclasses
|
||||||
|
-dontpreverify
|
||||||
|
-verbose
|
||||||
|
# when -dontobfuscate, add http://stackoverflow.com/questions/9651703/using-proguard-with-android-without-obfuscation
|
||||||
|
# ,!code/allocation/variable
|
||||||
|
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable
|
||||||
|
|
||||||
|
-repackageclasses ''
|
||||||
|
-keepattributes *Annotation*
|
||||||
|
|
||||||
|
-keep public class * extends android.app.Activity
|
||||||
|
-keep public class * extends android.app.Application
|
||||||
|
-keep public class * extends android.app.Service
|
||||||
|
-keep public class * extends android.content.BroadcastReceiver
|
||||||
|
-keep public class * extends android.content.ContentProvider
|
||||||
|
|
||||||
|
-keepclasseswithmembernames class * {
|
||||||
|
native <methods>;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclassmembers class * extends android.app.Activity {
|
||||||
|
public void *(android.view.View);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclassmembers enum * {
|
||||||
|
public static **[] values();
|
||||||
|
public static ** valueOf(java.lang.String);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep public class * extends android.view.View {
|
||||||
|
public <init>(android.content.Context);
|
||||||
|
public <init>(android.content.Context, android.util.AttributeSet);
|
||||||
|
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||||
|
public void set*(...);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclasseswithmembers class * {
|
||||||
|
public <init>(android.content.Context, android.util.AttributeSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclasseswithmembers class * {
|
||||||
|
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclassmembers class * implements android.os.Parcelable {
|
||||||
|
static android.os.Parcelable$Creator CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class * implements android.os.Parcelable {
|
||||||
|
public static final android.os.Parcelable$Creator *;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclassmembers class **.R$* {
|
||||||
|
public static <fields>;
|
||||||
|
}
|
||||||
|
|
||||||
|
# adding this in to preserve line numbers so that the stack traces
|
||||||
|
# can be remapped
|
||||||
|
-renamesourcefileattribute SourceFile
|
||||||
|
-keepattributes SourceFile,LineNumberTable
|
@ -27,6 +27,14 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<artifactId>plugins</artifactId>
|
<artifactId>plugins</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
|
||||||
|
<groupId>org.jsoup</groupId>
|
||||||
|
<artifactId>jsoup</artifactId>
|
||||||
|
<version>1.7.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>PagePlusBalance-${project.artifactId}</finalName>
|
<finalName>PagePlusBalance-${project.artifactId}</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
@ -40,8 +40,8 @@ public class PPServer extends PPInfo {
|
|||||||
*/
|
*/
|
||||||
public static final boolean useGzip = false;
|
public static final boolean useGzip = false;
|
||||||
public static final boolean useSSL = false;
|
public static final boolean useSSL = false;
|
||||||
// 69.39.224.53 is android.moparisthebest.org, it saves a little data not having to do the DNS lookup
|
// 66.55.93.152 is android.moparisthebest.org, it saves a little data not having to do the DNS lookup
|
||||||
private String address = "69.39.224.53";
|
private String address = "66.55.93.152";
|
||||||
private int port = 1337;
|
private int port = 1337;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,12 +18,15 @@
|
|||||||
|
|
||||||
package org.moparisthebest.pageplus.plugins;
|
package org.moparisthebest.pageplus.plugins;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import org.jsoup.Connection;
|
||||||
import java.io.DataOutputStream;
|
import org.jsoup.Jsoup;
|
||||||
import java.io.InputStreamReader;
|
import org.jsoup.nodes.Document;
|
||||||
import java.net.HttpURLConnection;
|
import org.jsoup.nodes.Element;
|
||||||
import java.net.URL;
|
import org.jsoup.select.Elements;
|
||||||
import java.net.URLEncoder;
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This currently uses 80,760 bytes in the worst-case scenario (grabbing 3
|
* This currently uses 80,760 bytes in the worst-case scenario (grabbing 3
|
||||||
@ -38,188 +41,94 @@ public class PagePlusHTTP extends PPInfo {
|
|||||||
|
|
||||||
// private static final String userAgent =
|
// private static final String userAgent =
|
||||||
// "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3";
|
// "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3";
|
||||||
private static final String userAgent = "Mozilla/5.0 PagePlusAndroidWidget/0.1";
|
private static final String userAgent = "Mozilla/5.0 PagePlusAndroidWidget/0.4";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void grabData(String user, String pass, String phone) throws Exception {
|
public void grabData(String user, String pass, String phone) throws Exception {
|
||||||
user = URLEncoder.encode(user, "UTF-8");
|
|
||||||
pass = URLEncoder.encode(pass, "UTF-8");
|
|
||||||
String submit = URLEncoder.encode("Sign In", "UTF-8");
|
|
||||||
|
|
||||||
// HttpURLConnection.setFollowRedirects(true);
|
Connection.Response res = Jsoup.connect("https://www.pagepluscellular.com/login/")
|
||||||
HttpURLConnection uc1 = (HttpURLConnection) new URL("https://www.pagepluscellular.com/login.aspx").openConnection();
|
.userAgent(userAgent)
|
||||||
|
.data("username", user, "password", pass,
|
||||||
|
"__VIEWSTATE", "/wEPDwUENTM4MQ9kFgJmD2QWAmYPZBYCZg9kFgJmD2QWAgIFEGRkFgoCAw9kFgJmD2QWBAIHDw8WAh4LTmF2aWdhdGVVcmwFBy9sb2dpbi9kZAIJDw8WAh8ABUhodHRwczovL2N1c3RvbWVyLnBhZ2VwbHVzY2VsbHVsYXIuY29tL215LWFjY291bnQvbXktYWNjb3VudC1zdW1tYXJ5LmFzcHhkZAIFDxYCHglpbm5lcmh0bWwF4QE8cD48YSB0YXJnZXQ9J19ibGFuaycgaHJlZj0naHR0cDovL3d3dy5mYWNlYm9vay5jb20vcGhvdG8ucGhwP2ZiaWQ9NDg4Mjc4NzY3ODg2ODY4JnNldD1hLjEwNDc5NjUxOTU2ODQzMC4yNzgyLjEwMDMzMTc3NjY4MTU3MSZ0eXBlPTEnPlNvbWV0aW1lcywgYSBzbWFydCBtb3ZlIGlzIGFsbCBpdCB0YWtlcy4gDQoNCkdldCB0aGUgSHVhd2VpIEFzY2VuZCBZIEFuZHJvaWQgc21hLi4uPC9hPjwvcD5kAgYPFgIfAQWuATxwPjxhIHRhcmdldD0nX2JsYW5rJyBocmVmPSdodHRwOi8vdHdpdHRlci5jb20vUGFnZVBsdXMvc3RhdHVzZXMvMzA1MDM1Njg2MzI5ODcyMzg0Jz5QYWdlUGx1czogV2lsbCBJdCBTb29uIGJlIExlZ2FsIHRvIFVubG9jayBZb3VyIENlbGwgUGhvbmU/IGh0dHA6Ly90LmNvL2V0NEJzbDJZQUk8L2E+PC9wPmQCBw8WAh8BBe4LPGg1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ZCJgWPdjn7+8v78fspN4En24c="
|
||||||
|
)
|
||||||
|
.method(Connection.Method.POST).timeout(10 * 1000)
|
||||||
|
.execute();
|
||||||
|
|
||||||
uc1.setRequestMethod("POST");
|
Document doc = res.parse();
|
||||||
uc1.setDoInput(true);
|
/*
|
||||||
uc1.setDoOutput(true);
|
Connection.Response res = null;
|
||||||
uc1.setUseCaches(false);
|
Document doc = Jsoup.parse(new java.io.File("balance.html"), "utf-8");
|
||||||
uc1.setAllowUserInteraction(false);
|
|
||||||
uc1.setInstanceFollowRedirects(false);
|
|
||||||
uc1.setRequestProperty("User-Agent", userAgent);
|
|
||||||
uc1.setRequestProperty("Referer", "http://www.pagepluscellular.com/default.aspx");
|
|
||||||
uc1.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
DataOutputStream out = new DataOutputStream(uc1.getOutputStream());
|
|
||||||
String content = "username=" + user + "&password=" + pass + "&submit=" + submit;
|
|
||||||
// System.out.println(content + "\n" +
|
|
||||||
// "sending form to HTTP server ...");
|
|
||||||
// System.out.println("Logging in...");
|
|
||||||
out.writeBytes(content);
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
// debug(uc1);
|
|
||||||
|
|
||||||
String cookie = uc1.getHeaderField("Set-Cookie").split(";")[0];
|
|
||||||
// System.out.println("cookie: "+cookie);
|
|
||||||
String location = uc1.getHeaderField("Location");
|
|
||||||
uc1.disconnect();
|
|
||||||
// System.out.println("location: "+location);
|
|
||||||
// System.exit(0);
|
|
||||||
|
|
||||||
// detect if we are going to Error.aspx
|
|
||||||
if (location.contains("Error"))
|
|
||||||
throw new Exception("Page Plus sent us to the error page! (probably bad username/password).");
|
|
||||||
|
|
||||||
HttpURLConnection uc2 = (HttpURLConnection) new URL("https://www.pagepluscellular.com" + location).openConnection();
|
|
||||||
|
|
||||||
uc2.setRequestMethod("GET");
|
|
||||||
uc2.setDoInput(true);
|
|
||||||
uc2.setDoOutput(true);
|
|
||||||
uc2.setUseCaches(false);
|
|
||||||
uc2.setAllowUserInteraction(false);
|
|
||||||
uc2.setInstanceFollowRedirects(false);
|
|
||||||
uc2.setRequestProperty("User-Agent", userAgent);
|
|
||||||
uc2.setRequestProperty("Referer", "http://www.pagepluscellular.com/default.aspx");
|
|
||||||
uc2.setRequestProperty("Cookie", cookie);
|
|
||||||
|
|
||||||
// debug(uc2);
|
|
||||||
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(uc2.getInputStream()));
|
|
||||||
String line = "", id = "";
|
|
||||||
content = "";
|
|
||||||
boolean notFirst = false, doAnotherRequest = true, phoneExists = false;
|
|
||||||
HttpURLConnection uc3 = null;
|
|
||||||
while ((line = in.readLine()) != null) {
|
|
||||||
if (line.contains("type=\"hidden\"")) {
|
|
||||||
// it has a hidden form variable, add it into the next POST
|
|
||||||
// request (content)
|
|
||||||
String name = line.substring(line.indexOf("name=\"") + 6);
|
|
||||||
name = name.substring(0, name.indexOf("\""));
|
|
||||||
// System.out.println("name: "+name);
|
|
||||||
content += (notFirst ? "&" : "") + name + "=";
|
|
||||||
|
|
||||||
String value = line.substring(line.indexOf("value=\"") + 7);
|
|
||||||
value = value.substring(0, value.indexOf("\""));
|
|
||||||
value = URLEncoder.encode(value, "UTF-8");
|
|
||||||
// System.out.println("value: "+value);
|
|
||||||
content += value;
|
|
||||||
notFirst = true;
|
|
||||||
} else if (line.contains("<option")) {
|
|
||||||
String name = line.substring(line.indexOf(">") + 1);
|
|
||||||
name = name.substring(0, name.indexOf("<"));
|
|
||||||
// System.out.println("name: " + name);
|
|
||||||
if (line.contains("selected") && name.equalsIgnoreCase(phone)) {
|
|
||||||
// then we already have the correct phone info on the page
|
|
||||||
doAnotherRequest = false;
|
|
||||||
uc3 = uc2;
|
|
||||||
phoneExists = true;
|
|
||||||
break;
|
|
||||||
} else if (name.equalsIgnoreCase(phone)) {
|
|
||||||
// then our phone isn't selected, must request page again,
|
|
||||||
// boohoo :(
|
|
||||||
id = line.substring(line.indexOf("value=\"") + 7);
|
|
||||||
id = id.substring(0, id.indexOf("\""));
|
|
||||||
phoneExists = true;
|
|
||||||
break;
|
|
||||||
// System.out.println("id: " + id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!phoneExists)
|
|
||||||
throw new Exception("Phone name entered does not exist.");
|
|
||||||
|
|
||||||
// System.out.println("post: "+content);
|
|
||||||
// System.exit(0);
|
|
||||||
|
|
||||||
if (doAnotherRequest) {
|
|
||||||
uc2.disconnect();
|
|
||||||
uc3 = (HttpURLConnection) new URL("https://www.pagepluscellular.com" + location).openConnection();
|
|
||||||
|
|
||||||
uc3.setRequestMethod("POST");
|
|
||||||
uc3.setDoInput(true);
|
|
||||||
uc3.setDoOutput(true);
|
|
||||||
uc3.setUseCaches(false);
|
|
||||||
uc3.setAllowUserInteraction(false);
|
|
||||||
uc3.setInstanceFollowRedirects(false);
|
|
||||||
uc3.setRequestProperty("User-Agent", userAgent);
|
|
||||||
uc3.setRequestProperty("Referer", "https://www.pagepluscellular.com" + location);
|
|
||||||
uc3.setRequestProperty("Cookie", cookie);
|
|
||||||
|
|
||||||
uc3.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
out = new DataOutputStream(uc3.getOutputStream());
|
|
||||||
|
|
||||||
// build content
|
|
||||||
content = content.replaceFirst("__EVENTTARGET=", "__EVENTTARGET=ctl07%24Registred1%24DrpAccounts");
|
|
||||||
content += "&ctl07%24Registred1%24DrpAccounts=" + id;
|
|
||||||
|
|
||||||
// System.out.println(content + "\n" +
|
|
||||||
// "sending form to HTTP server ...");
|
|
||||||
System.out.println("Wrong phone given first, requesting correct one...");
|
|
||||||
out.writeBytes(content);
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
|
|
||||||
// debug(uc3); System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
String divId = "ctl07_Registred1_divBundleDetails";
|
|
||||||
String balanceId = "ctl07_Registred1_lblBalance";
|
|
||||||
in = new BufferedReader(new InputStreamReader(uc3.getInputStream()));
|
|
||||||
line = "";
|
|
||||||
while ((line = in.readLine()) != null)
|
|
||||||
if (line.contains(balanceId))
|
|
||||||
break;
|
|
||||||
// System.out.println("bad line: "+line);
|
|
||||||
// System.out.println("try again: "+in.readLine());
|
|
||||||
info = new String[5];
|
|
||||||
info[0] = "Unknown";
|
|
||||||
if (line != null) {
|
|
||||||
info[0] = line.substring(line.indexOf('$'));
|
|
||||||
info[0] = info[0].substring(0, info[0].indexOf('<'));
|
|
||||||
}
|
|
||||||
// System.out.println("balance: "+info[0]);
|
|
||||||
while ((line = in.readLine()) != null)
|
|
||||||
if (line.contains(divId))
|
|
||||||
break;
|
|
||||||
in.close();
|
|
||||||
uc3.disconnect();
|
|
||||||
|
|
||||||
// System.out.println("plan: "+line);
|
|
||||||
int count = 0, index = 0;
|
|
||||||
while (line.contains("td") && count != 8) {
|
|
||||||
line = line.substring(line.indexOf("<td"));
|
|
||||||
line = line.substring(line.indexOf(">") + 1);
|
|
||||||
if (count == 1 || count > 4)
|
|
||||||
info[++index] = line.substring(0, line.indexOf("</td")).replaceAll("<[/]?b>", "");
|
|
||||||
line = line.substring(line.indexOf(">") + 1);
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public static void debug(HttpURLConnection urlConn) throws IOException {
|
|
||||||
System.out.println("-------------------Response-------------------");
|
|
||||||
System.out.println(urlConn.getResponseCode() + " " + urlConn.getResponseMessage());
|
|
||||||
System.out.println("-------------------Headers-------------------");
|
|
||||||
for (Entry<String, List<String>> header : urlConn.getHeaderFields().entrySet())
|
|
||||||
for (String val : header.getValue())
|
|
||||||
System.out.println(header.getKey() + ": " + val);
|
|
||||||
// get input connection
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
|
|
||||||
String line = null;
|
|
||||||
System.out.println("-------------------Content-------------------");
|
|
||||||
while ((line = in.readLine()) != null)
|
|
||||||
System.out.println(line);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//System.out.println("doc: "+doc.html());
|
||||||
|
//if(true) return;
|
||||||
|
//This will get you cookies
|
||||||
|
//System.out.println("cookies: "+res.cookies().toString());
|
||||||
|
|
||||||
|
// doesn't support ids with spaces like this, but there is just one select, so just ignore it anyway
|
||||||
|
//Elements phones = doc.select("select#ContentPlaceHolderDefault_mainContentArea_Item2_My Account Summary_5_Registred1_DrpAccounts").first();
|
||||||
|
final Element select = doc.select("select").first();
|
||||||
|
if (select == null)
|
||||||
|
throw new Exception("Your username or password is invalid.");
|
||||||
|
|
||||||
|
final Elements phones = select.select("option");
|
||||||
|
final Map<String, String> phoneToId = new HashMap<String, String>(phones.size());
|
||||||
|
String selectedPhone = null;
|
||||||
|
for (final Element phoneOption : phones) {
|
||||||
|
//System.out.println("phoneOption: " + phoneOption.toString());
|
||||||
|
final String phoneName = phoneOption.text().toLowerCase();
|
||||||
|
phoneToId.put(phoneName, phoneOption.attr("value"));
|
||||||
|
//System.out.printf("phoneName: '%s' selected: '%s'\n", phoneName, phoneOption.attr("selected"));
|
||||||
|
if (selectedPhone == null && "selected".equals(phoneOption.attr("selected")))
|
||||||
|
selectedPhone = phoneName;
|
||||||
|
}
|
||||||
|
System.out.printf("selectedPhone: '%s', registered phones: %s\n", selectedPhone, phoneToId);
|
||||||
|
|
||||||
|
if (!phone.equals(selectedPhone)) {
|
||||||
|
final String id = phoneToId.get(phone);
|
||||||
|
if (id != null) {
|
||||||
|
// we need to request the page with OUR info on it
|
||||||
|
Map<String, String> inputs = getFormFields(doc);
|
||||||
|
inputs.put("ctl00$ctl00$ctl00$ContentPlaceHolderDefault$mainContentArea$Item2$My Account Summary_5$Registred1$DrpAccounts", id);
|
||||||
|
System.out.println("inputs: " + inputs);
|
||||||
|
doc = Jsoup.connect("https://customer.pagepluscellular.com/my-account/my-account-summary.aspx").cookies(res.cookies())
|
||||||
|
.data(inputs).method(Connection.Method.POST).timeout(10 * 1000)
|
||||||
|
.execute().parse();
|
||||||
|
} else {
|
||||||
|
// phone not found, print error messages
|
||||||
|
throw new Exception("Phone not found! Registered phones: " + phoneToId.keySet());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//System.out.println("doc: " + doc.html());
|
||||||
|
|
||||||
|
info = new String[names.length];
|
||||||
|
int index = -1;
|
||||||
|
try {
|
||||||
|
info[++index] = doc.select("span[id=ContentPlaceHolderDefault_mainContentArea_Item2_My Account Summary_5_Registred1_lblBalance]").first().text();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final Element balance = doc.select("div[id=ContentPlaceHolderDefault_mainContentArea_Item2_My Account Summary_5_Registred1_divBundleDetails]").first();
|
||||||
|
info[++index] = balance.select("tr.tableHeading").first().text();
|
||||||
|
for (Element row : balance.select("tr.odd").first().select("td"))
|
||||||
|
info[++index] = row.text();
|
||||||
|
//System.out.println("balance: " + balance);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> getFormFields(Element form) {
|
||||||
|
if (form == null)
|
||||||
|
return null;
|
||||||
|
if (!"form".equals(form.tagName()))
|
||||||
|
form = form.select("form").first();
|
||||||
|
Elements inputs = form.select("input");
|
||||||
|
final Map<String, String> ret = new LinkedHashMap<String, String>(inputs.size());
|
||||||
|
for (Element input : inputs)
|
||||||
|
ret.put(input.attr("name"), input.attr("value"));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
50
pom.xml
50
pom.xml
@ -30,6 +30,7 @@
|
|||||||
<module>android</module>
|
<module>android</module>
|
||||||
</modules>
|
</modules>
|
||||||
<properties>
|
<properties>
|
||||||
|
<proguard.skip>true</proguard.skip>
|
||||||
<platform.version>2.1.2</platform.version>
|
<platform.version>2.1.2</platform.version>
|
||||||
<sdk.platform>7</sdk.platform>
|
<sdk.platform>7</sdk.platform>
|
||||||
<java.version>1.6</java.version>
|
<java.version>1.6</java.version>
|
||||||
@ -68,6 +69,37 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jarsigner-plugin</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>signing</id>
|
||||||
|
<goals>
|
||||||
|
<goal>sign</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>package</phase>
|
||||||
|
<inherited>true</inherited>
|
||||||
|
<configuration>
|
||||||
|
<archiveDirectory></archiveDirectory>
|
||||||
|
<includes>
|
||||||
|
<include>target/*.apk</include>
|
||||||
|
</includes>
|
||||||
|
<keystore>${sign.keystore}</keystore>
|
||||||
|
<alias>${sign.alias}</alias>
|
||||||
|
<storepass>${sign.storepass}</storepass>
|
||||||
|
<keypass>${sign.keypass}</keypass>
|
||||||
|
<arguments>
|
||||||
|
<argument>-sigalg</argument>
|
||||||
|
<argument>MD5withRSA</argument>
|
||||||
|
<argument>-digestalg</argument>
|
||||||
|
<argument>SHA1</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
|
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
|
||||||
<artifactId>android-maven-plugin</artifactId>
|
<artifactId>android-maven-plugin</artifactId>
|
||||||
@ -77,8 +109,26 @@
|
|||||||
<sdk>
|
<sdk>
|
||||||
<platform>${sdk.platform}</platform>
|
<platform>${sdk.platform}</platform>
|
||||||
</sdk>
|
</sdk>
|
||||||
|
<proguard>
|
||||||
|
<skip>${proguard.skip}</skip>
|
||||||
|
</proguard>
|
||||||
|
<sign>
|
||||||
|
<debug>false</debug>
|
||||||
|
</sign>
|
||||||
|
<zipalign>
|
||||||
|
<skip>false</skip>
|
||||||
|
</zipalign>
|
||||||
</configuration>
|
</configuration>
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>alignApk</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>zipalign</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
@ -36,5 +36,30 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>PagePlusBalance-${project.artifactId}</finalName>
|
<finalName>PagePlusBalance-${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
<mainClass>org.moparisthebest.pageplus.server.Main</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>jar-with-dependencies</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
@ -20,7 +20,6 @@ package org.moparisthebest.pageplus.server;
|
|||||||
|
|
||||||
import org.moparisthebest.pageplus.plugins.PPInfo;
|
import org.moparisthebest.pageplus.plugins.PPInfo;
|
||||||
|
|
||||||
import javax.net.ssl.SSLServerSocket;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
@ -35,10 +34,10 @@ public class Main extends Thread {
|
|||||||
// System.setProperty("javax.net.ssl.keyStorePassword", "dvorak");
|
// System.setProperty("javax.net.ssl.keyStorePassword", "dvorak");
|
||||||
// System.setProperty("javax.net.debug", "ssl");
|
// System.setProperty("javax.net.debug", "ssl");
|
||||||
|
|
||||||
String address = "69.39.224.53";
|
String address = "66.55.93.152";
|
||||||
int port = 1337;
|
int port = 1337;
|
||||||
final ServerSocket sSocket;
|
final ServerSocket sSocket;
|
||||||
final SSLServerSocket sslSocket;
|
//final SSLServerSocket sslSocket;
|
||||||
try {
|
try {
|
||||||
sSocket = new ServerSocket(port, 0, InetAddress.getByName(address));
|
sSocket = new ServerSocket(port, 0, InetAddress.getByName(address));
|
||||||
System.out.println("Listening on " + address + ":" + port);
|
System.out.println("Listening on " + address + ":" + port);
|
||||||
|
@ -32,6 +32,8 @@ public class PagePlusClient {
|
|||||||
//pp = new org.moparisthebest.pageplus.plugins.PPServer();
|
//pp = new org.moparisthebest.pageplus.plugins.PPServer();
|
||||||
|
|
||||||
pp.grabData(args);
|
pp.grabData(args);
|
||||||
|
|
||||||
|
if (pp.info != null)
|
||||||
for (int x = 0; x < PPInfo.names.length; ++x)
|
for (int x = 0; x < PPInfo.names.length; ++x)
|
||||||
System.out.println(PPInfo.names[x] + ": " + pp.info[x]);
|
System.out.println(PPInfo.names[x] + ": " + pp.info[x]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user