Results 1 to 16 of 16

Thread: Find and replace byte in exe files (find byte on the basis of it's offset)

  1. #1

    Thread Starter
    Addicted Member ßädbö¥'s Avatar
    Join Date
    Jul 2003
    Location
    I Lost somewhere !!
    Posts
    198

    Wink Find and replace byte in exe files (find byte on the basis of it's offset)

    Hi.. gurus..

    I've some work 4 u...

    i'm trying to find a hex value in a exe file... i have the offset value of that byte.. i want to find that hex value by using the offset value for that byte..
    how can i do taht ?????

    need urgent help...

    Thnx...

    ßädbö¥ Rü£z

    ICQ # : 204178672
    AOL SN : Badboy9jan
    badboy9jan<img src="images/smilies/s...g" />gmail.com

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    Well, if I remember random access, you could use that with the put statement (if I remember that correctly). Seeing as your editing hex values in an executable, I think you'll be able to use it
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  3. #3
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Random or Binary should work fine.

  4. #4

    Thread Starter
    Addicted Member ßädbö¥'s Avatar
    Join Date
    Jul 2003
    Location
    I Lost somewhere !!
    Posts
    198
    OK....??

    but how can i find that character using it's offset value
    I just ve the offset value of the character i want to replace.

    Suppose i want to find the (hex Value) 74 26 from whatever.exe and i only know it's offset (:40AB7B). then how can i find 74 26 by using it's Offset :40AB7A from the exe file....

    ßädbö¥ Rü£z

    ICQ # : 204178672
    AOL SN : Badboy9jan
    badboy9jan<img src="images/smilies/s...g" />gmail.com

  5. #5
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    Like we (kinda) said, look up Binary or Random [file] access in MSDN or here on the forums.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  6. #6
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Well, it's rather simple.

    For this I'd use Binary.

    VB Code:
    1. Dim bChr(1) as Byte
    2. Open file for Binary as #1
    3. Get #1,val("&H40AB7B"), bChr
    4. If bChr(0) = val("&H74") and bchr(1) = val("&H26") then
    5. bChr(0) = val("&hFF")
    6. bChr(1) = val("&hFF")
    7. Put #1, val("H40AB7B"), bChr
    8. end if
    9. Close #1

  7. #7

    Thread Starter
    Addicted Member ßädbö¥'s Avatar
    Join Date
    Jul 2003
    Location
    I Lost somewhere !!
    Posts
    198
    Thanx DiGiTaIErRoR

    But this code dosen't work....!! i tried it on my file. when i search on that (offset) address through Vb it shows diffrent byte but if i open that file in hex editor then the value 74 26 is on that address.... if u 've another way then plz suggest me... if u've any ASM code then also it will helpful to me....

    thanx

    ßädbö¥ Rü£z

    ICQ # : 204178672
    AOL SN : Badboy9jan
    badboy9jan<img src="images/smilies/s...g" />gmail.com

  8. #8
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    It worked fine for me... (I should say, after I added 1 to the offset it worked fine for me)
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  9. #9

    Thread Starter
    Addicted Member ßädbö¥'s Avatar
    Join Date
    Jul 2003
    Location
    I Lost somewhere !!
    Posts
    198
    Jemidiah can u send me your code ?

    ßädbö¥ Rü£z

    ICQ # : 204178672
    AOL SN : Badboy9jan
    badboy9jan<img src="images/smilies/s...g" />gmail.com

  10. #10
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    All I did was copy DiGiTaIErRoR's code and replace 'file' with some text file I had sitting around, and incremented the offset by one (Val(whatever the hex offset was) + 1)
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  11. #11
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    My code works, you just have the wrong offset.

    Try:

    Get #1,val("&H40AB7C"), bChr

    Also change the Put!

  12. #12

    Thread Starter
    Addicted Member ßädbö¥'s Avatar
    Join Date
    Jul 2003
    Location
    I Lost somewhere !!
    Posts
    198
    I tried it. It works fine for starting bytes like offset address 0, 10, 260 etc. but not for entire file....

    I used this Code....

    Private Sub Command1_Click()
    Dim bChr(1) As Byte
    Open "C:\target.exe" For Binary As #1
    Get #1, Val("&H4037A0") + 1, bChr ' In file it's 28 (hex value)

    MsgBox Hex(bChr(0))

    If bChr(0) = Val("&H28") And bChr(1) = Val("&H00") Then
    MsgBox "I GOT IT!!"
    End If
    Close #1

    End Sub



    I m attaching my file... u just check that file....

    and plz send me working code ASAP

    thanx
    Attached Files Attached Files

    ßädbö¥ Rü£z

    ICQ # : 204178672
    AOL SN : Badboy9jan
    badboy9jan<img src="images/smilies/s...g" />gmail.com

  13. #13
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    That target.exe file is wayyy too small for your offset.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  14. #14
    Addicted Member
    Join Date
    Feb 2003
    Posts
    237
    you got your offsets from debugger, you have to subtract base load address to get actual offset in file
    Free Code, papers, tools, and more

    http://sandsprite.com

  15. #15

    Thread Starter
    Addicted Member ßädbö¥'s Avatar
    Join Date
    Jul 2003
    Location
    I Lost somewhere !!
    Posts
    198
    Ok..... and how can i do that ???. I got that offset from hexeditor and debugger. both shows same offset for that byte. and one more thing ... What is the base load address and how can i substract base load address ? plz explain with example if possible....

    Thanx

    ßädbö¥ Rü£z

    ICQ # : 204178672
    AOL SN : Badboy9jan
    badboy9jan<img src="images/smilies/s...g" />gmail.com

  16. #16

    Thread Starter
    Addicted Member ßädbö¥'s Avatar
    Join Date
    Jul 2003
    Location
    I Lost somewhere !!
    Posts
    198
    I m waiting ....

    ßädbö¥ Rü£z

    ICQ # : 204178672
    AOL SN : Badboy9jan
    badboy9jan<img src="images/smilies/s...g" />gmail.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width