Created
November 2, 2011 20:46
-
-
Save elecyb/1334865 to your computer and use it in GitHub Desktop.
sha1calc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Text; | |
using System.Security.Cryptography; | |
using System.IO; | |
namespace shacalc | |
{ | |
class Program | |
{ | |
public static string Encode(string input, byte[] key) | |
{ | |
HMACSHA1 myhmacsha1 = new HMACSHA1(key); | |
byte[] byteArray = Encoding.ASCII.GetBytes(input.ToUpper()); | |
MemoryStream stream = new MemoryStream(byteArray); | |
return (myhmacsha1.ComputeHash(stream).Aggregate("", (s, e) => s + String.Format("{0:x2}", e), s => s)).ToUpper(); | |
} | |
static void Main(string[] args) | |
{ | |
//MODULE_CHECK: HMACSHA1(random_seed).ComputeHash(GetBytes(UPPER_CASE("some.dll"))) | |
//PAGE_CHECK: HMACSHA1(random_seed).ComputeHash(baseAddress + address, length) can be used for dll checks.. | |
string str = "4D5A"; // data | |
UInt32 rand = 0xFFFFFFFF; // random shit | |
byte[] seed = BitConverter.GetBytes(rand); | |
string result = Encode(str, seed); | |
// generate txt | |
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); | |
path = path.Substring(6, path.Length-6); | |
System.Console.WriteLine(path + "\\sha1.txt"); | |
System.Console.WriteLine(result); | |
System.IO.StreamWriter file = new System.IO.StreamWriter(path + "\\sha1.txt", false); | |
file.WriteLine(result); | |
file.Close(); | |
System.Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment