Untitled

 avatar
unknown
plain_text
3 years ago
3.0 kB
46
Indexable
public class Index {
    public static void main(String[] args) {
        final String refreshToken = "eyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyAiaXNzIjogInN0ZWFtIiwgInN1YiI6ICI3NjU2MTE5ODA2ODEyNjc2OSIsICJhdWQiOiBbICJ3ZWIiLCAicmVuZXciLCAiZGVyaXZlIiBdLCAiZXhwIjogMTY4MTc4OTkxNCwgIm5iZiI6IDE2NjM0NjA3NjYsICJpYXQiOiAxNjYzNDYwNzc2LCAianRpIjogIjE2N0NfMjE0RDM0RDVfMDZCQUMiLCAib2F0IjogMTY2MzQ2MDc3NiwgInBlciI6IDEsICJpcF9zdWJqZWN0IjogIjIwMS4xNDMuNDEuODgiLCAiaXBfY29uZmlybWVyIjogIjIwMS4xNDMuNDEuODgiIH0.n4r2q_YBFosylKPI6vMgihhvO2HK56_HA8JRhV-9esTKuCABmNWieMC78AkV-CMZEFDo2PfyOj33UntBefE0DA";
        final String redir = "https://store.steampowered.com/login/?redir=&redir_ssl=1&snr=1_4_4__global-header";
        byte[]  resBuf = new byte[12];
        new SecureRandom().nextBytes(resBuf);
        String  sessionId = Hex.encodeHexString(resBuf);
        try {
            //Realizing connection to steam
            Connection.Response response = Jsoup.connect("https://login.steampowered.com/jwt/finalizelogin")
                    .method(Connection.Method.POST)
                    .ignoreContentType(true)
                    .data("nonce", refreshToken)
                    .data("sessionid", sessionId)
                    .data("redir",redir)
                    .execute();

            //Converting body of the response into JSON, so we can extract "transfer_info"
            JSONObject setTokenJSON = new JSONObject(response.body());
            System.out.println(setTokenJSON);
            String auth = setTokenJSON.getJSONArray("transfer_info").getJSONObject(0).getJSONObject("params").get("auth").toString();
            String nonce = setTokenJSON.getJSONArray("transfer_info").getJSONObject(0).getJSONObject("params").get("nonce").toString();
            String setTokenURL = "https://store.steampowered.com/login/settoken";
            String steamID = "76561198068126769";


            //Getting cookies to secure log in
            response = Jsoup.connect(setTokenURL)
                    .data("steamID",steamID)
                    .data("nonce",nonce)
                    .data("auth",auth)
                    .ignoreContentType(true)
                    .execute();
            String loggedInBrowserId = response.cookies().get("browserid");
            String loggedInSessionId = response.cookies().get("sessionid");
            String loggedInCookie = response.cookies().get("steamLoginSecure");


            //Veryfing log in
            response = Jsoup.connect("https://steamcommunity.com/actions/GetNotificationCounts")
                    .cookie("browserid",loggedInBrowserId)
                    .cookie("sessionid",loggedInSessionId)
                    .cookie("steamLoginSecure",loggedInCookie)
                    .ignoreContentType(true)
                    .execute();
            System.out.println(response.body());

        } catch (IOException e) {
            throw new RuntimeException(e);
            }
    }
}




Editor is loading...