측면 이동 침투 테스트: Python을 사용한 Chrome 북마크 추출

Feb 25 2023
R. Eric Kiser 침투 테스터로서 손상된 사용자 또는 시스템에 대해 가능한 한 많은 정보를 수집하는 것이 중요합니다.

R. 에릭 키저

침투 테스터로서 손상된 사용자 또는 시스템에 대해 가능한 한 많은 정보를 수집하는 것이 중요합니다. 측면 이동에 유용한 기술은 Google 크롬에서 북마크를 추출하여 사용자가 자주 액세스하는 리소스를 찾는 것입니다. 얻은 책갈피를 사용하여 스크립트를 사용하여 정보를 수집하거나 GUI 원격 액세스가 있는 경우 수동으로 각 페이지를 방문하여 암호를 추출할 수 있는지 확인할 수 있습니다.

데이터를 추출하려면 몇 개의 모듈을 가져와야 합니다. 파일 시스템에 액세스하고 파일을 복사하기 위해 가져옵니다 os. 플랫폼을 확인하고 임시 디렉토리를 생성하기 위해 가져옵니다 .shutilimport sysimport tempfile

import os
import sys
import shutil
import tempfile

bookmarks_file = os.path.expanduser('~/Library/Application Support/Google/Chrome/Default/Bookmarks')

if sys.platform == 'win32':
    bookmarks_file = os.path.expandvars(r'%LOCALAPPDATA%\Google\Chrome\User Data\Default\Bookmarks')
elif sys.platform == 'darwin':
    bookmarks_file = os.path.expanduser('~/Library/Application Support/Google/Chrome/Default/Bookmarks')

if not os.path.exists(bookmarks_file):
    print('Error: unable to locate your bookmarks file')
    sys.exit(1)

temp_dir = tempfile.mkdtemp()

try:
    shutil.copy2(bookmarks_file, temp_dir)
    bookmarks_file = os.path.join(temp_dir, os.path.basename(bookmarks_file))

    with open(bookmarks_file, 'r') as f:
        data = f.read()

    with open('bookmarks.html', 'w') as f:
        f.write(data)

finally:
    shutil.rmtree(temp_dir)

print ("bookmarks successfully downloaded in the current working directory")