메뉴 건너뛰기

조회 수 27057 추천 수 0 댓글 3
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

출처 :

http://stackoverflow.com/questions/1026483/is-there-a-way-to-crack-the-password-on-an-excel-vba-project/31005696#31005696

 

암호묻는 다이어로그 창의 리턴값을 1로 고정시켜서 암호를 맞게 입력한것으로 속이는 방법이다.

 

 

Excel 2007
Excel 2010
Excel 2013
Excel 2016

 

 

1. 락이걸린 엑셀파일을 연다.

2. 새 xlsm 파일을 생성한다.

3. Alt+F11 을 눌러 VBA를 실행한후 새로 만든 파일의 프로젝트를 선택하고 위의 메뉴의 Insert->Module 해서

   Module1 에 다음 코드를 복사해 넣는다 64bit 엑셀프로그램은 아래의 64bit 버전용 코드를 대신 삽입니다.

 

Excel 32bit 버전용 코드

 

Option Explicit

Private Const PAGE_EXECUTE_READWRITE = &H40

Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _
        (Destination As Long, Source As Long, ByVal Length As Long)

Private Declare Function VirtualProtect Lib "kernel32" (lpAddress As Long, _
        ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long

Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long

Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _
        ByVal lpProcName As String) As Long

Private Declare Function DialogBoxParam Lib "user32" Alias "DialogBoxParamA" (ByVal hInstance As Long, _
        ByVal pTemplateName As Long, ByVal hWndParent As Long, _
        ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Integer

Dim HookBytes(0 To 5) As Byte
Dim OriginBytes(0 To 5) As Byte
Dim pFunc As Long
Dim Flag As Boolean

Private Function GetPtr(ByVal Value As Long) As Long
    GetPtr = Value
End Function

Public Sub RecoverBytes()
    If Flag Then MoveMemory ByVal pFunc, ByVal VarPtr(OriginBytes(0)), 6
End Sub

Public Function Hook() As Boolean
    Dim TmpBytes(0 To 5) As Byte
    Dim p As Long
    Dim OriginProtect As Long

    Hook = False

    pFunc = GetProcAddress(GetModuleHandleA("user32.dll"), "DialogBoxParamA")


    If VirtualProtect(ByVal pFunc, 6, PAGE_EXECUTE_READWRITE, OriginProtect) <> 0 Then

        MoveMemory ByVal VarPtr(TmpBytes(0)), ByVal pFunc, 6
        If TmpBytes(0) <> &H68 Then

            MoveMemory ByVal VarPtr(OriginBytes(0)), ByVal pFunc, 6

            p = GetPtr(AddressOf MyDialogBoxParam)

            HookBytes(0) = &H68
            MoveMemory ByVal VarPtr(HookBytes(1)), ByVal VarPtr(p), 4
            HookBytes(5) = &HC3

            MoveMemory ByVal pFunc, ByVal VarPtr(HookBytes(0)), 6
            Flag = True
            Hook = True
        End If
    End If
End Function

Private Function MyDialogBoxParam(ByVal hInstance As Long, _
        ByVal pTemplateName As Long, ByVal hWndParent As Long, _
        ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Integer
    If pTemplateName = 4070 Then
        MyDialogBoxParam = 1
    Else
        RecoverBytes
        MyDialogBoxParam = DialogBoxParam(hInstance, pTemplateName, _
                           hWndParent, lpDialogFunc, dwInitParam)
        Hook
    End If
End Function

 

64bit 버전 엑셀용 코드

 

Option Explicit

Private Const PAGE_EXECUTE_READWRITE = &H40

Private Declare PtrSafe Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As LongPtr, Source As LongPtr, ByVal Length As LongPtr)

Private Declare PtrSafe Function VirtualProtect Lib "kernel32" (lpAddress As LongPtr, _
ByVal dwSize As LongPtr, ByVal flNewProtect As LongPtr, lpflOldProtect As LongPtr) As LongPtr

Private Declare PtrSafe Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As LongPtr

Private Declare PtrSafe Function GetProcAddress Lib "kernel32" (ByVal hModule As LongPtr, _
ByVal lpProcName As String) As LongPtr

Private Declare PtrSafe Function DialogBoxParam Lib "user32" Alias "DialogBoxParamA" (ByVal hInstance As LongPtr, _
ByVal pTemplateName As LongPtr, ByVal hWndParent As LongPtr, _
ByVal lpDialogFunc As LongPtr, ByVal dwInitParam As LongPtr) As Integer

Dim HookBytes(0 To 5) As Byte
Dim OriginBytes(0 To 5) As Byte
Dim pFunc As LongPtr
Dim Flag As Boolean

Private Function GetPtr(ByVal Value As LongPtr) As LongPtr
    GetPtr = Value
End Function

Public Sub RecoverBytes()
    If Flag Then MoveMemory ByVal pFunc, ByVal VarPtr(OriginBytes(0)), 6
End Sub

Public Function Hook() As Boolean
    Dim TmpBytes(0 To 5) As Byte
    Dim p As LongPtr
    Dim OriginProtect As LongPtr

    Hook = False

    pFunc = GetProcAddress(GetModuleHandleA("user32.dll"), "DialogBoxParamA")


    If VirtualProtect(ByVal pFunc, 6, PAGE_EXECUTE_READWRITE, OriginProtect) <> 0 Then

        MoveMemory ByVal VarPtr(TmpBytes(0)), ByVal pFunc, 6
        If TmpBytes(0) <> &H68 Then

            MoveMemory ByVal VarPtr(OriginBytes(0)), ByVal pFunc, 6

            p = GetPtr(AddressOf MyDialogBoxParam)

            HookBytes(0) = &H68
            MoveMemory ByVal VarPtr(HookBytes(1)), ByVal VarPtr(p), 4
            HookBytes(5) = &HC3

            MoveMemory ByVal pFunc, ByVal VarPtr(HookBytes(0)), 6
            Flag = True
            Hook = True
        End If
    End If
End Function

Private Function MyDialogBoxParam(ByVal hInstance As LongPtr, _
ByVal pTemplateName As LongPtr, ByVal hWndParent As LongPtr, _
ByVal lpDialogFunc As LongPtr, ByVal dwInitParam As LongPtr) As Integer

    If pTemplateName = 4070 Then
        MyDialogBoxParam = 1
    Else
        RecoverBytes
        MyDialogBoxParam = DialogBoxParam(hInstance, pTemplateName, _
                   hWndParent, lpDialogFunc, dwInitParam)
        Hook
    End If
End Function

 

4. 같은방법으로 Insert->Module로 모듈생성후 Module2 에 다음코드를 복사한다

 

Sub unprotected()
    If Hook Then
        MsgBox "VBA Project is unprotected!", vbInformation, "*****"
    End If
End Sub

 

5. F5를 눌러 unprotected를 선택해 실행한다

 

6. 이제 암호걸렸던 VBA Project를 열어보면 더이상 암호를 묻지 않게된다. 도구의 프로젝트 속성에 가서 protected 모드를 해제하면 완벽히 제거된다.

 

 

  • ?
    dalongi 2016.10.03 08:48
    옹 뒤뒤 아재가 다시 게시판 활동하는 건가 ㅋㅋ
  • ?
    DDART 2017.09.08 09:03
    와우.. 회원가입해서 댓글 다는 사람이 다 있네.. 당신 스토커야? ㅋㅋ 아재라니... 말씀이 좀 지나치시군.. 다롱아재.
  • ?
    초보컴맹 2018.04.26 01:18
    안녕하세요. 위에 설명대로 했는데 엑셀파일 오류가 계속 걸릴는데 그럼 vba비번 풀수없는건가여?

  1. MariaDB 외부접속시 ssl 사용법, 그리고 ssl 로 replication(동기화) 하기

  2. No Image 11Jul
    by DDART
    2020/07/11 by DDART
    Views 3602 

    터미널에서 backspace 키가 안눌러질때

  3. No Image 07Jul
    by DDART
    2020/07/07 by DDART
    Views 3715 

    서버사이 동기화하기 - rsync, mariadb replication

  4. No Image 17May
    by DDART
    2020/05/17 by DDART
    Views 4376 

    msinfo 시스템정보 wmic cmd 명령

  5. No Image 21Jan
    by DDART
    2020/01/21 by DDART
    Views 4814 

    Visual Studio Code 에서 Autohotkey 설정

  6. No Image 22Dec
    by DDART
    2019/12/22 by DDART
    Views 2621 

    우분투 19.04, 19.10, 20.04 으로 업그레이드 하기

  7. No Image 09Sep
    by DDART
    2019/09/09 by DDART
    Views 3495 

    윈도우 10에서 구글 어시스턴트 명령

  8. No Image 12Jun
    by DDART
    2019/06/12 by DDART
    Views 3730 

    해외 IP차단

  9. No Image 11Jun
    by DDART
    2019/06/11 by DDART
    Views 317217 

    Fail2Ban 설정하기

  10. No Image 01Jun
    by DDART
    2019/06/01 by DDART
    Views 8149 

    윈도우 자동화관련 툴

  11. No Image 31Oct
    by DDART
    2018/10/31 by DDART
    Views 15225 

    PHP로 WOL Magic Packet 보내기

  12. No Image 16Oct
    by DDART
    2018/10/16 by DDART
    Views 5102 

    BATCH 문법

  13. No Image 15Oct
    by DDART
    2018/10/15 by DDART
    Views 2917 

    우분투 16.04 에서 18.04 로 업그레이드하기

  14. No Image 14Oct
    by DDART
    2018/10/14 by DDART
    Views 5965 

    Windows 7, 8.1 에서 Windows 10으로 무료업그레이드하기

  15. No Image 12Dec
    by DDART
    2017/12/12 by DDART
    Views 3169 

    vsftpd 설정

  16. No Image 08Sep
    by DDART
    2017/09/08 by DDART
    Views 9336 

    crontab

  17. VBA Project 패스워드 보호 제거하기

  18. No Image 05Aug
    by DDART
    2016/08/05 by DDART
    Views 6372 

    우분투 16.04 ownCloud 9.1.0 설치

  19. No Image 31Jul
    by DDART
    2016/07/31 by DDART
    Views 12397 

    우분투 16.04 Subversion - SVN서버, SVN+SSH 클라이언트

  20. No Image 31Jul
    by DDART
    2016/07/31 by DDART
    Views 4405 

    우분투 16.04 FTP, Samba 등 가상디렉토리 추가

Board Pagination Prev 1 2 3 ... 4 Next
/ 4