Guest User

Untitled

a guest
May 18th, 2013
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Specialized;
  4. using System.Net;
  5. using System.Text;
  6. using System.Web;
  7. using System.Security.Cryptography;
  8. using Newtonsoft.Json;
  9. using System.Security.Cryptography.X509Certificates;
  10. using System.Net.Security;
  11.  
  12. namespace RsaGOD
  13. {
  14. public class rif
  15. {
  16.  
  17. public static string rsarif(string user,string pass)
  18. {
  19. var data = new NameValueCollection();
  20. data.Add("username", user);
  21. string response = Fetch("https://steamcommunity.com/login/getrsakey", "POST", data, null, false);
  22. var rsaJSON = JsonConvert.DeserializeObject<GetRsaKey>(response);
  23. //RSA Encryption
  24. RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
  25. RSAParameters rsaParameters = new RSAParameters();
  26.  
  27. rsaParameters.Exponent = HexToByte(rsaJSON.publickey_exp);
  28. rsaParameters.Modulus = HexToByte(rsaJSON.publickey_mod);
  29.  
  30. rsa.ImportParameters(rsaParameters);
  31.  
  32. byte[] bytePassword = Encoding.ASCII.GetBytes(pass);
  33. byte[] encodedPassword = rsa.Encrypt(bytePassword, false);
  34. return Convert.ToBase64String(encodedPassword);
  35.  
  36.  
  37. }
  38. #region gamno
  39.  
  40. static int GetHexVal(char hex)
  41. {
  42. int val = (int)hex;
  43. return val - (val < 58 ? 48 : 55);
  44. }
  45.  
  46.  
  47. public static string Fetch(string url, string method, NameValueCollection data, CookieContainer cookies, bool ajax )
  48. {
  49. data = null;cookies = null;ajax = true;
  50. HttpWebResponse response = Request(url, method, data, cookies, ajax);
  51. StreamReader reader = new StreamReader(response.GetResponseStream());
  52. return reader.ReadToEnd();
  53. }
  54.  
  55. public static HttpWebResponse Request(string url, string method, NameValueCollection data, CookieContainer cookies, bool ajax)
  56. {
  57. data = null; cookies = null; ajax = true;
  58. HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
  59.  
  60. request.Method = method;
  61.  
  62. request.Accept = "text/javascript, text/html, application/xml, text/xml, */*";
  63. request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
  64. request.Host = "steamcommunity.com";
  65. request.UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11";
  66. request.Referer = "http://steamcommunity.com/trade/1";
  67.  
  68. if (ajax)
  69. {
  70. request.Headers.Add("X-Requested-With", "XMLHttpRequest");
  71. request.Headers.Add("X-Prototype-Version", "1.7");
  72. }
  73.  
  74. // Cookies
  75. request.CookieContainer = cookies ?? new CookieContainer();
  76.  
  77. // Request data
  78. if (data != null)
  79. {
  80. string dataString = String.Join("&", Array.ConvertAll(data.AllKeys, key =>
  81. String.Format("{0}={1}", key,data[key])
  82. )
  83. );
  84.  
  85. byte[] dataBytes = Encoding.ASCII.GetBytes(dataString);
  86. request.ContentLength = dataBytes.Length;
  87.  
  88. Stream requestStream = request.GetRequestStream();
  89. requestStream.Write(dataBytes, 0, dataBytes.Length);
  90. }
  91.  
  92. // Get the response
  93. return request.GetResponse() as HttpWebResponse;
  94. }
  95. public class GetRsaKey
  96. {
  97. public bool success { get; set; }
  98.  
  99. public string publickey_mod { get; set; }
  100.  
  101. public string publickey_exp { get; set; }
  102.  
  103. public string timestamp { get; set; }
  104. }
  105.  
  106.  
  107.  
  108.  
  109. static byte[] HexToByte(string hex)
  110. {
  111. if (hex.Length % 2 == 1)
  112. throw new Exception("The binary key cannot have an odd number of digits");
  113.  
  114. byte[] arr = new byte[hex.Length >> 1];
  115. int l = hex.Length;
  116.  
  117. for (int i = 0; i < (l >> 1); ++i)
  118. {
  119. arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
  120. }
  121.  
  122. return arr;
  123. }
  124. #endregion;
  125.  
  126.  
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment