메뉴 건너뛰기

조회 수 26885 추천 수 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(동기화) 하기

    Date2020.07.12 ByDDART Views10723
    Read More
  2. 터미널에서 backspace 키가 안눌러질때

    Date2020.07.11 ByDDART Views3462
    Read More
  3. 서버사이 동기화하기 - rsync, mariadb replication

    Date2020.07.07 ByDDART Views3529
    Read More
  4. msinfo 시스템정보 wmic cmd 명령

    Date2020.05.17 ByDDART Views4219
    Read More
  5. Visual Studio Code 에서 Autohotkey 설정

    Date2020.01.21 ByDDART Views4653
    Read More
  6. 우분투 19.04, 19.10, 20.04 으로 업그레이드 하기

    Date2019.12.22 ByDDART Views2463
    Read More
  7. 윈도우 10에서 구글 어시스턴트 명령

    Date2019.09.09 ByDDART Views3315
    Read More
  8. 해외 IP차단

    Date2019.06.12 ByDDART Views3575
    Read More
  9. Fail2Ban 설정하기

    Date2019.06.11 ByDDART Views316959
    Read More
  10. 윈도우 자동화관련 툴

    Date2019.06.01 ByDDART Views8001
    Read More
  11. PHP로 WOL Magic Packet 보내기

    Date2018.10.31 ByDDART Views15028
    Read More
  12. BATCH 문법

    Date2018.10.16 ByDDART Views4847
    Read More
  13. 우분투 16.04 에서 18.04 로 업그레이드하기

    Date2018.10.15 ByDDART Views2767
    Read More
  14. Windows 7, 8.1 에서 Windows 10으로 무료업그레이드하기

    Date2018.10.14 ByDDART Views5842
    Read More
  15. vsftpd 설정

    Date2017.12.12 ByDDART Views3017
    Read More
  16. crontab

    Date2017.09.08 ByDDART Views9204
    Read More
  17. VBA Project 패스워드 보호 제거하기

    Date2016.09.22 ByDDART Views26885
    Read More
  18. 우분투 16.04 ownCloud 9.1.0 설치

    Date2016.08.05 ByDDART Views6299
    Read More
  19. 우분투 16.04 Subversion - SVN서버, SVN+SSH 클라이언트

    Date2016.07.31 ByDDART Views12309
    Read More
  20. 우분투 16.04 FTP, Samba 등 가상디렉토리 추가

    Date2016.07.31 ByDDART Views4323
    Read More
Board Pagination Prev 1 2 3 ... 4 Next
/ 4