-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFormatShellcode.cs
More file actions
34 lines (30 loc) · 967 Bytes
/
FormatShellcode.cs
File metadata and controls
34 lines (30 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Text;
using System.IO;
namespace FormatShellcode
{
public static void PrintShellcode(byte[] shellcodeBytes)
{
StringBuilder shellcode = new StringBuilder();
shellcode.Append("byte[] shellcode = new byte[");
shellcode.Append(shellcodeBytes.Length);
shellcode.Append("] { ");
for(int i = 0; i < shellcodeBytes.Length; i++)
{
shellcode.Append("0x");
shellcode.AppendFormat("{0:x2}", shellcodeBytes[i]);
if(i < shellcodeBytes.Length -1)
{
shellcode.Append(", ");
}
}
shellcode.Append(" };");
Console.WriteLine(shellcode.ToString());
}
public static void Main(string[] args)
{
byte[] shellcode = File.ReadAllBytes(args[0]);
PrintShellcode(shellcode);
}
}
}