Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections.Specialized;
- using System.Net;
- using System.Text;
- using System.Web;
- using System.Security.Cryptography;
- using Newtonsoft.Json;
- using System.Security.Cryptography.X509Certificates;
- using System.Net.Security;
- namespace RsaGOD
- {
- public class rif
- {
- public static string rsarif(string user,string pass)
- {
- var data = new NameValueCollection();
- data.Add("username", user);
- string response = Fetch("https://steamcommunity.com/login/getrsakey", "POST", data, null, false);
- var rsaJSON = JsonConvert.DeserializeObject<GetRsaKey>(response);
- //RSA Encryption
- RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
- RSAParameters rsaParameters = new RSAParameters();
- rsaParameters.Exponent = HexToByte(rsaJSON.publickey_exp);
- rsaParameters.Modulus = HexToByte(rsaJSON.publickey_mod);
- rsa.ImportParameters(rsaParameters);
- byte[] bytePassword = Encoding.ASCII.GetBytes(pass);
- byte[] encodedPassword = rsa.Encrypt(bytePassword, false);
- return Convert.ToBase64String(encodedPassword);
- }
- #region gamno
- static int GetHexVal(char hex)
- {
- int val = (int)hex;
- return val - (val < 58 ? 48 : 55);
- }
- public static string Fetch(string url, string method, NameValueCollection data, CookieContainer cookies, bool ajax )
- {
- data = null;cookies = null;ajax = true;
- HttpWebResponse response = Request(url, method, data, cookies, ajax);
- StreamReader reader = new StreamReader(response.GetResponseStream());
- return reader.ReadToEnd();
- }
- public static HttpWebResponse Request(string url, string method, NameValueCollection data, CookieContainer cookies, bool ajax)
- {
- data = null; cookies = null; ajax = true;
- HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
- request.Method = method;
- request.Accept = "text/javascript, text/html, application/xml, text/xml, */*";
- request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
- request.Host = "steamcommunity.com";
- request.UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11";
- request.Referer = "http://steamcommunity.com/trade/1";
- if (ajax)
- {
- request.Headers.Add("X-Requested-With", "XMLHttpRequest");
- request.Headers.Add("X-Prototype-Version", "1.7");
- }
- // Cookies
- request.CookieContainer = cookies ?? new CookieContainer();
- // Request data
- if (data != null)
- {
- string dataString = String.Join("&", Array.ConvertAll(data.AllKeys, key =>
- String.Format("{0}={1}", key,data[key])
- )
- );
- byte[] dataBytes = Encoding.ASCII.GetBytes(dataString);
- request.ContentLength = dataBytes.Length;
- Stream requestStream = request.GetRequestStream();
- requestStream.Write(dataBytes, 0, dataBytes.Length);
- }
- // Get the response
- return request.GetResponse() as HttpWebResponse;
- }
- public class GetRsaKey
- {
- public bool success { get; set; }
- public string publickey_mod { get; set; }
- public string publickey_exp { get; set; }
- public string timestamp { get; set; }
- }
- static byte[] HexToByte(string hex)
- {
- if (hex.Length % 2 == 1)
- throw new Exception("The binary key cannot have an odd number of digits");
- byte[] arr = new byte[hex.Length >> 1];
- int l = hex.Length;
- for (int i = 0; i < (l >> 1); ++i)
- {
- arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
- }
- return arr;
- }
- #endregion;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment