Coderlar; crypter, packer, loader gibi programları yapıp istenilen Exe'li uygulamaları kırmak için Hex ham kodları değiştirirler. Bunun için HxD, Hex Editor Neo, Hex Editor, WinHEX, Hex Workshop gibi programlar kullanarak manuel editlemeler yaparlar. Aşağıdaki kodlarla isteyen arkadaşlar otomatik olarak bulup değiştirme işlemini Hex bazlı olarak VB.NET yada C#.NET te yapabilirler...
Yazı editöründe SQL Injection filtrelemesi olduğu için tek tırnak ve çift tırnaklar filtreleniyor. Bu nedenle kodlarda;
Çift tırnak yerine ----------> çift yıldız yıldız (**)
Tek tırnak yerine ----------> tek yıldız (*) kullanılmıştır.
VB.NET:
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
* Trsz_kwT
* http://www.ajanlar.org
Imports System.IO
Imports System.Text
Public Class Form1
Dim anaPath As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim anaPath As String = **C:\Users\Admin\Desktop\1.jpg**
fromFileReplaceWithHexCode(anaPath, **5472737A5f6B7754**, **9090909090909090**) *hex => Trsz_kwT
End Sub
Private Sub fromFileReplaceWithHexCode(ByVal path As String, ByVal oldHex As String, ByVal newHex As String)
* ▼---------------------- Hex kodundan offset bul ---------------------▼
Dim strTemp As String
Dim byteTemp(newHex.Length - 1) As Byte
For i As Integer = 0 To oldHex.Length - 1 Step 2
strTemp &= ChrW(**&H** & oldHex.Substring(i, 2))
byteTemp(i) = AscW(**&H** & newHex.Substring(i, 2))
Next
Dim offset As Integer = File.ReadAllText(path).IndexOf(strTemp)
* ------------------------------------------------------------------------
* ▼---------- Değiştirilen Hex koduyla dosyayı tekrar oluştur ----------▼
Using dosya = New BinaryWriter(File.Open(path, FileMode.Open))
dosya.Seek(offset, SeekOrigin.Begin)
For Each byteB In byteTemp
dosya.Write(byteB)
Next
End Using
* ------------------------------------------------------------------------
End Sub
End Class
-------------------------------------------------------------------------------------
C#.NET:
--------------------------------------------------------------------------------------
// Trsz_kwT
//http://www.ajanlar.org
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Text;
public class Form1
{
string anaPath;
private void Form1_Load(object sender, EventArgs e)
{
string anaPath = **C:\\Users\\Admin\\Desktop\\1.jpg**;
fromFileReplaceWithHexCode(anaPath, **5472737A5f6B7754**, **9090909090909090**);
//hex => Trsz_kwT
}
private void fromFileReplaceWithHexCode(string path, string oldHex, string newHex)
{
// ▼---------------------- Hex kodundan offset bul ---------------------▼
string strTemp;
byte[] byteTemp = new byte[newHex.Length];
for (int i = 0; i <= oldHex.Length - 1; i += 2) {
strTemp += Strings.ChrW(**&H** + oldHex.Substring(i, 2));
byteTemp(i) = Strings.AscW(**&H** + newHex.Substring(i, 2));
}
int offset = File.ReadAllText(path).IndexOf(strTemp);
// ------------------------------------------------------------------------
// ▼---------- Değiştirilen Hex koduyla dosyayı tekrar oluştur ----------▼
using (dosya == new BinaryWriter(File.Open(path, FileMode.Open))) {
dosya.Seek(offset, SeekOrigin.Begin);
foreach (void byteB_loopVariable in byteTemp) {
byteB = byteB_loopVariable;
dosya.Write(byteB);
}
}
// ------------------------------------------------------------------------
}
public Form1()
{
Load += Form1_Load;
}
}