rootx Posted August 2, 2015 Posted August 2, 2015 I want to replace this value with autoit, usually I do that with HxD editor and replace selection utility.I'm able to find the exact value but I do not understand how to replace it, can someone explain me how to do it?Thx.My code#include <String.au3> #include <Array.au3> $file = "myfile" $read = FileRead($file) $filhex = _StringToHex($read) $split = StringRegExp($filhex, "(?s).{1,2}", 3) $kb = 0 $sp = "" $val = "" $row = 0 For $i = 0 To UBound($split) - 1 $kb += 1 If $kb < 16 Then $sp = " " $val &= $split[$i] & $sp ElseIf $kb = 16 Then $sp = @CRLF $val &= $split[$i] & $sp $kb = 0 $row += 1 EndIf Next ConsoleWrite($split[53]&@LF)
Danyfirex Posted August 2, 2015 Posted August 2, 2015 local $hFile=FileOpen("1.exe",512) Local $sData=FileRead($hFile) FileClose($hFile) Local $hFile2=FileOpen("2.exe",514) FileWrite($hFile2,StringReplace($sData,Chr(0x2B),Chr(0x2A),1)) FileClose($hFile2)That change the first found 2B for 2A. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
rootx Posted August 2, 2015 Author Posted August 2, 2015 local $hFile=FileOpen("1.exe",512) Local $sData=FileRead($hFile) FileClose($hFile) Local $hFile2=FileOpen("2.exe",514) FileWrite($hFile2,StringReplace($sData,Chr(0x2B),Chr(0x2A),1)) FileClose($hFile2)That change the first found 2B for 2A. SaludosThx one step forward...I used one array because I need to replace a lot of values dynamically without knowing the value inside the file but only the exactly position.For example at the position of the Array [12][22].......N replace with [AE][2B] ....NIn your example the target is the first occurrence... but I need to replace multiples values in one loop. Usually I used _FileReadToArray but Im not sure with Hex values the right way to do it.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now