Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 268176c

Browse files
authored
Merge pull request #20 from dev
2 parents 3385d9c + bc19382 commit 268176c

25 files changed

+568
-264
lines changed

AppManifest.xml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<ProjectConfig>
3+
<InfoConfig>
4+
<Name display="Instagram OSINT (Osintgram4j)" name="osintgram4j"/>
5+
<Version ver="0.2" code="1" />
6+
<Maintainers>
7+
<Maintainer>BC100Dev ([email protected])</Maintainer>
8+
</Maintainers>
9+
<Sources type="git" url="https://github.com/BeChris100/osintgram4j" branch="master" />
10+
</InfoConfig>
11+
<Modules>
12+
<Module name="core" executable="true" sources="src/">
13+
<Dependency name="org.json:json" />
14+
<ModLink name="ig_api" />
15+
<ModLink name="commons" />
16+
<ModLink name="mod_api"/>
17+
<Class binName="osintgram4j" main="net.bc100dev.osintgram4j.MainClass" />
18+
<Class binName="og4j-tests" main="net.bc100dev.osintgram4j.test.TestMain" scope="test" />
19+
</Module>
20+
<Module name="ig_api" executable="false" sources="instagram_api/src/">
21+
<Dependency name="org.json:json"/>
22+
<ModLink name="commons" />
23+
</Module>
24+
<Module name="mod_api" executable="false" sources="modapi/src/">
25+
<Dependency name="org.json:json"/>
26+
<ModLink name="commons" />
27+
</Module>
28+
<Module name="commons" executable="false" sources="modapi/src/" />
29+
<Module name="updater" executable="true" sources="updater/src/">
30+
<Class binName="og4j-updater" main="app.updater.UpdaterMain" />
31+
</Module>
32+
</Modules>
33+
</ProjectConfig>

NewREADME.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ With Privacy Policy in mind, you acknowledge:
2424
- **Logging**: Your actions are logged locally that can be used for debugging.
2525
- **No Server Uploads**: No data is being sent to any server without any explicit
2626
permission
27-
- **Privacy Focus**: Sensitive information is not specifically recorded.
27+
- **Sensitivity**: Some sensitive information is included, such as the commands that
28+
you type (e.g. usernames) in the interactive Shell
2829

2930
See the [full Privacy Policy](PrivacyPolicy.md) to review. Don't forget, use
3031
Osintgram4j responsibly, respect privacy of others, and always act ethically.
@@ -51,7 +52,7 @@ setup with the Shell scripts:
5152

5253
The `--force-download` is an optional parameter. If given, it will always download
5354
the JDK and the libraries, no matter its state. Otherwise, it will try to detect
54-
JDK 21, and get the latest `org.json` library.
55+
JDK 21, and get the latest `org.json` and `org.apache:commons-cli` library.
5556

5657
## Client Mods
5758
Osintgram4j introduces a Modding API, which is something that I like. Having the
@@ -61,4 +62,4 @@ outdated from its original source. Allowing to customize and extend is functiona
6162
is something anyone would want.
6263

6364
As always, prioritize privacy and security, along with downloading mods from trusted
64-
sources.
65+
sources.

README.md

+114-169
Large diffs are not rendered by default.

SECURITY.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
These following versions are currently supported:
5+
6+
| Version | Supported |
7+
|---------|--------------------|
8+
| 0.2 | :white_check_mark: |
9+
| 0.1 | :white_check_mark: |
10+
11+
## Reporting a Vulnerability
12+
Use this section to tell people how to report a vulnerability.
13+
14+
Tell them where to go, how often they can expect to get an update on a
15+
reported vulnerability, what to expect if the vulnerability is accepted or
16+
declined, etc.

build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ if [ "$#" -ne 0 ]; then
6262
echo "Uninstalling osintgram4j"
6363
"$PREFIX" rm -rf /usr/bin/osintgram4j
6464
"$PREFIX" rm -rf /usr/bin/og4j-editor
65+
"$PREFIX" rm -rf /usr/bin/og4j-logdata
6566

6667
if [ -d "/usr/share/osintgram4j" ]; then
6768
"$PREFIX" rm -rf /usr/share/osintgram4j

commons/src/net/bc100dev/commons/Terminal.java

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
public class Terminal {
44

5-
public static native int windowLines();
6-
public static native int windowColumns();
7-
85
public static void print(TermColor color, String msg, boolean reset) {
96
if (msg != null)
107
System.out.print(translateColor(color) + msg);

extres/coms/devices-example.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
{
1616
"manufacturer": "Apple",
1717
"model": "iPhone 13 Pro",
18-
"android": false,
19-
"ios": true,
18+
"os": "iOS",
2019
"client_type": "Browser",
2120
"client_app": {
2221
"application_version": ""
@@ -33,8 +32,7 @@
3332
{
3433
"manufacturer": "Google",
3534
"model": "Pixel 8 Pro",
36-
"android": true,
37-
"ios": false,
35+
"os": "Android",
3836
"client_type": "App",
3937
"client_app": {
4038
"application_version": ""
@@ -52,4 +50,4 @@
5250
"ios_values": {}
5351
}
5452
]
55-
}
53+
}
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[
2+
"25/7.1.1; 440dpi; 1080x1920; Xiaomi; Mi Note 3; jason; qcom",
3+
"23/6.0.1; 480dpi; 1080x1920; Xiaomi; Redmi Note 3; kenzo; qcom",
4+
"23/6.0; 480dpi; 1080x1920; Xiaomi; Redmi Note 4; nikel; mt6797",
5+
"24/7.0; 480dpi; 1080x1920; Xiaomi/xiaomi; Redmi Note 4; mido; qcom",
6+
"23/6.0; 480dpi; 1080x1920; Xiaomi; Redmi Note 4X; nikel; mt6797",
7+
"27/8.1.0; 440dpi; 1080x2030; Xiaomi/xiaomi; Redmi Note 5; whyred; qcom",
8+
"23/6.0.1; 480dpi; 1080x1920; Xiaomi; Redmi 4; markw; qcom",
9+
"27/8.1.0; 440dpi; 1080x2030; Xiaomi/xiaomi; Redmi 5 Plus; vince; qcom",
10+
"25/7.1.2; 440dpi; 1080x2030; Xiaomi/xiaomi; Redmi 5 Plus; vince; qcom",
11+
"26/8.0.0; 480dpi; 1080x1920; Xiaomi; MI 5; gemini; qcom",
12+
"27/8.1.0; 480dpi; 1080x1920; Xiaomi/xiaomi; Mi A1; tissot_sprout; qcom",
13+
"26/8.0.0; 480dpi; 1080x1920; Xiaomi; MI 6; sagit; qcom",
14+
"25/7.1.1; 440dpi; 1080x1920; Xiaomi; MI MAX 2; oxygen; qcom",
15+
"24/7.0; 480dpi; 1080x1920; Xiaomi; MI 5s; capricorn; qcom",
16+
"26/8.0.0; 480dpi; 1080x1920; samsung; SM-A520F; a5y17lte; samsungexynos7880",
17+
"26/8.0.0; 480dpi; 1080x2076; samsung; SM-G950F; dreamlte; samsungexynos8895",
18+
"26/8.0.0; 640dpi; 1440x2768; samsung; SM-G950F; dreamlte; samsungexynos8895",
19+
"26/8.0.0; 420dpi; 1080x2094; samsung; SM-G955F; dream2lte; samsungexynos8895",
20+
"26/8.0.0; 560dpi; 1440x2792; samsung; SM-G955F; dream2lte; samsungexynos8895",
21+
"24/7.0; 480dpi; 1080x1920; samsung; SM-A510F; a5xelte; samsungexynos7580",
22+
"26/8.0.0; 480dpi; 1080x1920; samsung; SM-G930F; herolte; samsungexynos8890",
23+
"26/8.0.0; 480dpi; 1080x1920; samsung; SM-G935F; hero2lte; samsungexynos8890",
24+
"26/8.0.0; 420dpi; 1080x2094; samsung; SM-G965F; star2lte; samsungexynos9810",
25+
"26/8.0.0; 480dpi; 1080x2076; samsung; SM-A530F; jackpotlte; samsungexynos7885",
26+
"24/7.0; 640dpi; 1440x2560; samsung; SM-G925F; zerolte; samsungexynos7420",
27+
"26/8.0.0; 420dpi; 1080x1920; samsung; SM-A720F; a7y17lte; samsungexynos7880",
28+
"24/7.0; 640dpi; 1440x2560; samsung; SM-G920F; zeroflte; samsungexynos7420",
29+
"24/7.0; 420dpi; 1080x1920; samsung; SM-J730FM; j7y17lte; samsungexynos7870",
30+
"26/8.0.0; 480dpi; 1080x2076; samsung; SM-G960F; starlte; samsungexynos9810",
31+
"26/8.0.0; 420dpi; 1080x2094; samsung; SM-N950F; greatlte; samsungexynos8895",
32+
"26/8.0.0; 420dpi; 1080x2094; samsung; SM-A730F; jackpot2lte; samsungexynos7885",
33+
"26/8.0.0; 420dpi; 1080x2094; samsung; SM-A605FN; a6plte; qcom",
34+
"26/8.0.0; 480dpi; 1080x1920; HUAWEI/HONOR; STF-L09; HWSTF; hi3660",
35+
"27/8.1.0; 480dpi; 1080x2280; HUAWEI/HONOR; COL-L29; HWCOL; kirin970",
36+
"26/8.0.0; 480dpi; 1080x2032; HUAWEI/HONOR; LLD-L31; HWLLD-H; hi6250",
37+
"26/8.0.0; 480dpi; 1080x2150; HUAWEI; ANE-LX1; HWANE; hi6250",
38+
"26/8.0.0; 480dpi; 1080x2032; HUAWEI; FIG-LX1; HWFIG-H; hi6250",
39+
"27/8.1.0; 480dpi; 1080x2150; HUAWEI/HONOR; COL-L29; HWCOL; kirin970",
40+
"26/8.0.0; 480dpi; 1080x2038; HUAWEI/HONOR; BND-L21; HWBND-H; hi6250",
41+
"23/6.0.1; 420dpi; 1080x1920; LeMobile/LeEco; Le X527; le_s2_ww; qcom"
42+
]
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
main-class=net.bc100dev.osintgram4j.LogMainClass
22
classpath=core.jar
3-
java-options=-Xmx256m -Xms128m -Dog4j.location.app_dir=$APPDIR -Dog4j.location.bin_dir=$BINDIR -Dog4j.location.root_dir=$ROOTDIR
3+
java-options=-Xmx128m -Xms64m -Dog4j.location.app_dir=$APPDIR -Dog4j.location.bin_dir=$BINDIR -Dog4j.location.root_dir=$ROOTDIR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.instagram.api;
2+
3+
public class APIException extends Exception {
4+
5+
public APIException() {
6+
super();
7+
}
8+
9+
public APIException(String message) {
10+
super(message);
11+
}
12+
13+
public APIException(String message, Throwable cause) {
14+
super(message, cause);
15+
}
16+
17+
public APIException(Throwable cause) {
18+
super(cause);
19+
}
20+
21+
protected APIException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
22+
super(message, cause, enableSuppression, writableStackTrace);
23+
}
24+
}

instagram_api/src/com/instagram/api/Constants.java

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.instagram.api;
22

3+
import java.util.HashMap;
4+
import java.util.Map;
5+
36
public class Constants {
47

58
public static final String URL_API = "https://i.instagram.com/api/v1";
@@ -10,6 +13,11 @@ public class Constants {
1013

1114
public static String LOCALE = "en_US";
1215

16+
public static Map<String, String> putDefaultHeaders() {
17+
Map<String, String> headers = new HashMap<>();
18+
return headers;
19+
}
20+
1321
public static class Privates {
1422

1523
/*

instagram_api/src/com/instagram/api/user/UserManager.java

+39-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
package com.instagram.api.user;
22

3+
import com.instagram.api.APIException;
34
import com.instagram.api.Constants;
45

56
import javax.crypto.Cipher;
67
import javax.crypto.spec.GCMParameterSpec;
78
import javax.crypto.spec.SecretKeySpec;
89
import javax.net.ssl.HttpsURLConnection;
10+
import java.io.IOException;
911
import java.nio.ByteBuffer;
1012
import java.security.GeneralSecurityException;
1113
import java.security.KeyFactory;
1214
import java.security.PublicKey;
1315
import java.security.SecureRandom;
1416
import java.security.spec.X509EncodedKeySpec;
1517
import java.util.Base64;
16-
import java.util.List;
18+
import java.util.HashMap;
1719
import java.util.Map;
20+
import java.util.logging.Level;
21+
22+
import static osintgram4j.commons.AppConstants.log_net;
1823

1924
public class UserManager {
2025

26+
/*
27+
private static final String FILTER_PLACEHOLDER_NAME = "__name__";
28+
private static final String FILTER_PLACEHOLDER_ID = "__userID__";
29+
private static final String FILTER_PLACEHOLDER_SESSION_ID = "__sessionID__";
30+
*/
31+
2132
/*
2233
TODO: Steps on encrypting the password, and logging in
2334
1. Retrieve the header values (see below comment from TypeScript/JavaScript)
@@ -33,7 +44,30 @@ public class UserManager {
3344
'ig-set-password-encryption-pub-key': pwPubKey,
3445
*/
3546

36-
public static User login(String username, String password) {
47+
public static User login(String username, String password) throws IOException, APIException {
48+
if (Constants.Privates.PASS_ENC_KEY_ID == null)
49+
throw new NullPointerException("Password Encryption Key ID has not been initialized");
50+
51+
if (Constants.Privates.PASS_ENC_PUB_KEY == null)
52+
throw new NullPointerException("Password Encryption Public Key has not been initialized");
53+
54+
if (Constants.Privates.IG_AUTH_HEADER == null)
55+
throw new NullPointerException("Instagram Authentication Header has not been initialized");
56+
57+
if (Constants.Privates.WWW_CLAIM == null)
58+
throw new NullPointerException("Instagram WWW Claim has not been initialized");
59+
60+
String encPass;
61+
try {
62+
encPass = PasswordEncryption.toEncryptedPassword(password.toCharArray());
63+
} catch (GeneralSecurityException ex) {
64+
log_net.log(Level.SEVERE, "Failed to encrypt password", ex);
65+
throw new APIException(ex);
66+
}
67+
68+
Map<String, String> loginHeaders = new HashMap<>(Constants.putDefaultHeaders());
69+
loginHeaders.put("enc_password", PasswordEncryption.writePassword(encPass));
70+
3771
//https://www.instagram.com/api/v1/accounts/login/ajax
3872
//https://www.instagram.com/api/v1/accounts/login/ajax?force_classic_login
3973

@@ -167,7 +201,7 @@ public static String writePassword(String encryptedPassword) {
167201
return String.format("#PWD_INSTAGRAM:4:%d:%s", timestamp, encryptedPassword);
168202
}
169203

170-
public static String toEncryptedPassword(String password) throws GeneralSecurityException {
204+
public static String toEncryptedPassword(char[] password) throws GeneralSecurityException {
171205
KeyFactory keyFact = KeyFactory.getInstance("RSA");
172206
X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(Base64.getDecoder().decode(Constants.Privates.PASS_ENC_PUB_KEY));
173207
PublicKey publicKey = keyFact.generatePublic(pubKeySpec);
@@ -189,7 +223,8 @@ public static String toEncryptedPassword(String password) throws GeneralSecurity
189223
long time = System.currentTimeMillis() / 1000L;
190224
aesCipher.updateAAD(String.valueOf(time).getBytes());
191225

192-
byte[] aesEncrypted = aesCipher.doFinal(password.getBytes());
226+
String _pass = new String(password);
227+
byte[] aesEncrypted = aesCipher.doFinal(_pass.getBytes());
193228
byte[] sizeBuffer = ByteBuffer.allocate(2).putShort((short) rsaEncrypted.length).array();
194229
byte[] authTag = aesCipher.getIV();
195230

src/net/bc100dev/osintgram4j/LogMainClass.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private static void execute(String pass, TypeAction action, File file) {
163163
public static void main(String[] args) {
164164
Options opts = new Options();
165165

166-
Option passOption = new Option("p", "pass", true, "The password used for encrypting the log file");
166+
Option passOption = new Option("p", "pass", true, "The password used for encrypting the log file (defaults to \"ask\", prompting for password)");
167167
passOption.setRequired(false);
168168
opts.addOption(passOption);
169169

@@ -175,7 +175,7 @@ public static void main(String[] args) {
175175
decryptOption.setRequired(false);
176176
opts.addOption(decryptOption);
177177

178-
Option openOption = new Option("o", "open", false, "Open a specific log file");
178+
Option openOption = new Option("o", "open", false, "Open a specific log file, and print its contents out");
179179
openOption.setRequired(false);
180180
opts.addOption(openOption);
181181

src/net/bc100dev/osintgram4j/cmd/AppManager.java src/net/bc100dev/osintgram4j/cmd/ClientManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.util.List;
99

10-
public class AppManager extends Command {
10+
public class ClientManager extends Command {
1111

1212
@Override
1313
public int launchCmd(String[] args, List<ShellEnvironment> env) {

0 commit comments

Comments
 (0)