fork(2) download
  1. using System;
  2. using System.Net.Sockets;
  3. using System.IO;
  4. using System.Security.Cryptography;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. string secret = "shienshenlhq";
  11. string placa = "PGM1833";
  12.  
  13. string placaHash;
  14.  
  15. System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
  16. byte[] keyByte = encoding.GetBytes(secret);
  17. byte[] messageBytes = encoding.GetBytes(placa);
  18. using (HMACSHA1 hmacsha1 = new HMACSHA1(keyByte))
  19. {
  20. byte[] hashmessage = hmacsha1.ComputeHash(messageBytes);
  21. placaHash = (HexStringFromBytes(hashmessage));
  22. Console.WriteLine(placaHash);
  23. }
  24.  
  25. string postData = "GT-S1312LAndroid1.1.14.1.4aplicativo177.206.169.90" + placaHash + "-3-38" + placa + "\n/sinesp-cidadao/ConsultaPlaca HTTP/1.1\r\r\n";
  26. byte[] bytes = Encoding.UTF8.GetBytes(postData);
  27.  
  28. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://s...content-available-to-author-only...v.br/sinesp-cidadao/ConsultaPlacaNovo27032014");
  29. request.ProtocolVersion = HttpVersion.Version11;
  30. request.Method = "POST";
  31. request.Host = "sinespcidadao.sinesp.gov.br";
  32. request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
  33. request.ContentLength = bytes.Length;
  34.  
  35. Stream requestStream = request.GetRequestStream();
  36. requestStream.Write(bytes, 0, bytes.Length);
  37.  
  38. WebResponse response = request.GetResponse();
  39. Stream stream = response.GetResponseStream();
  40. StreamReader reader = new StreamReader(stream);
  41.  
  42. var result = reader.ReadToEnd();
  43.  
  44. stream.Dispose();
  45. reader.Dispose();
  46.  
  47. Console.WriteLine(result.ToString());
  48. Console.ReadKey();
  49. }
  50.  
  51. public static string HexStringFromBytes(byte[] bytes)
  52. {
  53. var sb = new StringBuilder();
  54. foreach (byte b in bytes)
  55. {
  56. var hex = b.ToString("x2");
  57. sb.Append(hex);
  58. }
  59. return sb.ToString();
  60. }
  61. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(26,16): error CS0103: The name `Encoding' does not exist in the current context
prog.cs(28,1): error CS0246: The type or namespace name `HttpWebRequest' could not be found. Are you missing `System.Net' using directive?
prog.cs(29,27): error CS0103: The name `HttpVersion' does not exist in the current context
prog.cs(29,1): error CS0841: A local variable `request' cannot be used before it is declared
prog.cs(30,1): error CS0841: A local variable `request' cannot be used before it is declared
prog.cs(31,1): error CS0841: A local variable `request' cannot be used before it is declared
prog.cs(32,1): error CS0841: A local variable `request' cannot be used before it is declared
prog.cs(33,1): error CS0841: A local variable `request' cannot be used before it is declared
prog.cs(35,24): error CS0841: A local variable `request' cannot be used before it is declared
prog.cs(38,1): error CS0246: The type or namespace name `WebResponse' could not be found. Are you missing `System.Net' using directive?
prog.cs(39,17): error CS0841: A local variable `response' cannot be used before it is declared
prog.cs(53,14): error CS0246: The type or namespace name `StringBuilder' could not be found. Are you missing `System.Text' using directive?
Compilation failed: 12 error(s), 0 warnings
stdout
Standard output is empty