Screenshot:
Link:

Requires .NET 2.0
Edit:
Source (includes WAN/LAN ip difference)
Code:
using System;
using System.Collections.Generic;
using System.IO;
namespace srSpoof_patcher
{
class Program
{
static void Main(string[] args)
{
//TODO: nIP/ wIP - should be possible to make them different
string fileName = string.Empty;
string ip_wan = string.Empty;
string ip_lan = string.Empty;
Console.Title = "srSpoof_patcher [EBX7.NET], Chernobyl (2013) http://ebx7.net/";
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Blue;
comment();
Console.WriteLine("srSpoof_patcher [EBX7.NET], Chernobyl (2013)\nhttp://ebx7.net/");
comment();
Console.Write("File name to patch (example: MachineManager.exe):");
fileName = Console.ReadLine();
Console.Write("Enter WAN ip address to spoof (example: 195.130.25.13):");
ip_wan = Console.ReadLine();
Console.Write("Enter LAN ip address to spoof (example: 192.168.1.102):");
ip_lan = Console.ReadLine();
int img = 0x400000;
int bytesRequired = 100;
try
{
FileStream fs = File.Open(fileName, FileMode.Open);
//StreamReader sr = new StreamReader(fs);
BinaryReader br = new BinaryReader(fs);
long fileLength = br.BaseStream.Length;
long offset_write = 0;
br.BaseStream.Seek(0, SeekOrigin.Begin);
int sign_det1 = 0;
int sign_det2 = 0;
byte[] signature = new byte[] { 0x52, 0x50, 0x0F, 0xB6, 0xC9, 0x51 };
bool found = false;
for (int i = 0; i < fileLength - 1000; i++)
{
try
{
if (br.BaseStream.Position < (fileLength - signature.Length))
{
for (int a = 0; a < signature.Length; a++)
{
if (br.ReadByte() == signature[a])
{
found = true;
}
else
{
found = false;
// Console.WriteLine("not found");
break;
}
}
if (found)
{
Console.WriteLine("Found push addr by signature [RVA:0x{0:X}]", (int)br.BaseStream.Position + img);
if (sign_det1 == 0) sign_det1 = (int)br.BaseStream.Position + img;
else sign_det2 = (int)br.BaseStream.Position + img;
}
}
}
catch { }
}
if (sign_det1 == 0 || sign_det2 == 0)
{
Console.WriteLine("Something went wrong (one or both of addresses of push instructions are 0 !) - signature detection failed ?");
Console.ReadKey();
return;
}
br.BaseStream.Seek(0, SeekOrigin.Begin);
//for finding out if there's enough free space (0x00 bytes)
long nByte = 0;
for (int i = 0; i < fileLength - bytesRequired; i++)
{
if (br.ReadByte() == 0x00)
{
nByte++;
}
else nByte = 0;
if (nByte >= bytesRequired)
{
Console.WriteLine("Free space found at RVA offset [{0} bytes !] 0x{1:X} ", bytesRequired, (br.BaseStream.Position + img) - bytesRequired); //RVA offset
offset_write = br.BaseStream.Position + img - bytesRequired;
break;
}
}
//we dont need binary reader and it's filestream anymore
br.Close();
fs.Close();
FileStream fs_w = new FileStream(fileName, FileMode.Open);
BinaryWriter bw = new BinaryWriter(fs_w);
//writing ip string to free space we found
fs_w.Seek(offset_write - img, SeekOrigin.Begin);
byte[] ip_wan_bytes = ASCIIEncoding.ASCII.GetBytes(ip_wan);
for (int i = 0; i < ip_wan_bytes.Length; i++)
{
fs_w.WriteByte(ip_wan_bytes[i]);
}
Console.WriteLine("WRITEN new ip [wan] bytes to offset 0x{0:X} at free space !\nNow setting push instruction operands !", offset_write);
fs_w.Seek((offset_write - img) + ip_wan_bytes.Length + 5, SeekOrigin.Begin);
byte[] ip_lan_bytes = ASCIIEncoding.ASCII.GetBytes(ip_lan);
for(int i = 0; i < ip_lan_bytes.Length; i++)
{
fs_w.WriteByte(ip_lan_bytes[i]);
}
Console.WriteLine("WRITEN new ip [lan] bytes to offset 0x{0:X} at free space !", offset_write);
//+1 because of "push" instruction code
fs_w.Seek((sign_det1 - img) + 1, SeekOrigin.Begin);
//4 bytes of offset
//convert address to byte array (sizeof(int)) == 4
byte[] bytes_push1 = BitConverter.GetBytes(offset_write);
for (int i = 0; i < 4; i++)
{
fs_w.WriteByte(bytes_push1[i]);
}
Console.WriteLine("first push writen !");
//+1 because of "push" instruction code
fs_w.Seek((sign_det2 - img) + 1, SeekOrigin.Begin);
//convert address to byte array (sizeof(int)) == 4
byte[] bytes_push2 = BitConverter.GetBytes(offset_write + ip_lan_bytes.Length);
for (int i = 0; i < 4; i++)
{
fs_w.WriteByte(bytes_push2[i]);
}
Console.WriteLine("second push writen !");
bw.Close();
fs_w.Close();
comment();
Console.WriteLine("Patching finished !");
if (offset_write == 0)
{
Console.WriteLine("Something went wrong (no free space at PE ?!");
}
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine("Something went terribly wrong, exception: {0}", ex.Message);
Console.ReadKey();
}
}
private static void comment()
{
Console.WriteLine("--------------------------------------------");
}
}
}







