2012-11-28 3 views
0

현재 보안 감사에서 Windows 암호 해시 추출 프로세스를 간소화하고 있습니다. 개인적으로 감사를 수행 할 때 복구 된 사용자 및 암호 목록을 생성하는 프로세스를보다 쉽게 ​​만들고 싶습니다. 나는 또한 많은 양의 데이터를 비교하고 생성하려는 다른 사람들에게 유용 할 것이라고 생각한다. 나는 윈도우 시스템 파일에서 모든 데이터를 추출 할 때데이터 구조를 구현하여 NTLM 해시 파일 비교

, 나는 형식으로 사용자에게 아래로 단순화 :

그래서 여기가 요점이다 ". a87f3a357d73085c45f9416be5787e86"해시, 해시 등의 NTLM 해시입니다

그런 다음 oclHashcat을 사용하여 사전이나 무차별 대명사 이건 상관없이 해시를 해킹하려고 시도합니다. 문제가되지 않습니다. 해시 캣은 해시 형식의 암호로 생성합니다. 그러나 복구 된 해시의 출력을 생성합니다.

이제 내 문제는 무엇이고 어떤 입력을 원합니다. 나는 두 개의 입력 파일이 주어진 사용자 : 암호로 출력을 생성하려고합니다. 수백 개의 해시가 있지만 아직 복구 된 암호가 몇 개 밖에 없다는 것을 고려할 때 목록을 정렬하려는 시도는 없습니다.

어떤 데이터 구조가 가장 도움이되는지 확신 할 수 없습니다. 배열은 대형 테이블에 비해 너무 비효율적이었습니다. 직렬화에 대해 살펴 봤으며 해시 맵과 해시 테이블을 사용하고 있습니다. 해쉬의 크기를 감안할 때, 나는이 방법들 중 하나를 구현하는 행운을 얻지 못했고, 그렇게 잘못하고있다.

program [user:hash file] [hash:password file] -o [user:password output] 

그리고 효과적으로 그래서 (간략하게) 같은 프로그램을 실행하기 위해 노력하고있어 :

현재 나는과 같이 프로그램을 실행하는거야 난 단지 그림을 시도하고

Load Files 

// user:hash file 
For each line, split by ':' delimiter 
before delimiter = table1.user 
after delimiter = table1.hash 

// hash:password file 
For each line, split by ':' delimiter 
before delimiter = table2.hash 
after delimiter = table2.password 

// generate user:password file 
Check each entry of table1 vs table2 
if table1.hash = table2.hash 
    table1.user = output.user 
    table2.password = output.password 
    print to output "output.user:output.password" 

각 라인을 추적하고 필요한 데이터를 쉽게 추적 할 수있는 데이터 구조로 추출하는 효율적인 방법을 제시합니다.

무엇인가를 명확히해야하는 경우 알려 주시기 바랍니다. 어떤 도움을 주셔서 감사합니다!

+0

해시 문제에 대해 자세히 설명해 주시겠습니까? 또한, 왜 stl에있는 것들을 사용하는 대신 해시를 구현하고 있습니까? – RonaldBarzell

+0

글쎄, 처음부터 잘못 구현 한 것 같습니다. 그러나 그때 나는 그 데이터를 저장하는 다른 더 좋은 방법이 있는지 궁금해하기 시작했다. 내 해시를 사용하는 이유는 Hashcat 및 기타 소프트웨어의 출력물이기 때문이며 비교를 위해 필요합니다. – Signus

답변

0

필자는 쉘 스크립트를 사용하기로 결정했으며 관련 배열을 사용하여 req 내가 필요로하는 유익한 데이터.

참고 :이 프로그램의 대부분은 내 해시 파일의 형식을 처리합니다. 스크립트의 주석을보십시오.

#!/bin/bash 
# Signus 
# User-Password Hash Comparison Tool v1.0 
# Simple utility that allows for the comparison between a file with a 'user:hash' format to a separate file with a 'hash:password' format. The comparison matches the hashes and returns an output file in the format 'user:password' 

# Example of 'user:hash' -> george:c21cfaebe1d69ac9e2e4e1e2dc383bac 
# Example of 'hash:password' -> c21cfaebe1d69ac9e2e4e1e2dc383bac:password 
# 'user:hash' obtained from creddump suite: http://code.google.com/p/creddump/ 
# Note: Used custom 'dshashes.py' file: http://ptscripts.googlecode.com/svn/trunk/dshashes.py 
# 'hash:password' obtained from ocl-Hashcat output 

usage="Usage: $0 [-i user:hash input] [-t hash:password input] [-o output]" 

declare -a a1 
declare -a a2 
declare -A o 

index1=0 
index2=0 
countA1=0 
countA2=0 
matchCount=0 

if [ -z "$*" ]; then 
    echo $usage 
    exit 1 
fi 

if [ $# -ne 6 ]; then 
    echo "Error: Invalid number of arguments." 
    echo $usage 
    exit 1 
fi 

echo -e 
echo "---Checking Files---" 
while getopts ":i:t:o:" option; do 
    case $option in 
     i) inputFile1="$OPTARG" 
     if [ ! -f $inputFile1 ]; then 
      echo "Unable to find or open file: $inputFile1" 
      exit 1 
     fi 
     echo "Reading...$inputFile1" 
     ;; 
     t) inputFile2="$OPTARG" 
     if [ ! -f $inputFile2 ]; then 
      echo "Unable to find or open file: $inputFile2" 
      exit 1 
     fi 
     echo "Reading...$inputFile2" 
     ;; 
     o) outputFile="$OPTARG" 
     echo "Writing...$outputFile" 
     ;; 
     [?]) echo $usage >&2 
      exit 1 
     ;; 
    esac 
done 
shift $(($OPTIND-1)) 


#First read the files and cut each line into an array 
echo -e 
echo "---Reading Files---" 
while read LINE 
do 
    a1[$index1]="$LINE" 
    index1=$(($index1+1)) 
    countA1=$(($countA1+1)) 
done < $inputFile1 
echo "Read $countA1 lines in $inputFile1" 

while read LINE 
do 
    a2[$index2]="$LINE" 
    index2=$(($index2+1)) 
    countA2=$(($countA2+1)) 
done < $inputFile2 
echo "Read $countA2 lines in $inputFile2" 


#Then cut each item out of the array and store it into separate variables 
echo -e 
echo "Searching for Matches..." 
for ((j=0; j<${#a2[@]}; j++)) 
do 
    hash2=$(echo ${a2[$j]} | cut -d: -f1) 
    pword=$(echo ${a2[$j]} | cut -d: -f2) 

    for ((i=0; i<${#a1[@]}; i++)) 
    do 
     us=$(echo ${a1[$i]} | cut -d: -f1) 
     hash1=$(echo ${a1[$i]} | cut -d: -f2) 

     if [ "$hash2" = "$hash1" ]; then 
      matchCount=$(($matchCount+1)) 
      o["$us"]=$pword 
      echo -e "Match Found[$matchCount]: \t Username:$us \t Password:$pword" 
      break 
     fi 

    done 
done 

echo -e "Matches Found: $matchCount\n" >> $outputFile 
for k in ${!o[@]} 
do 
    echo -e "Username: $k \t Password: ${o[$k]}" >> $outputFile 
done 
echo -e "\nWrote $matchCount lines to $outputFile" 

unset o 
1

내 데이터 구조

std::map<std::string,std::string> hash_user_map; 

없음 모든 사용자를 통해 이동이 작업을 수행하고 1

For each user in table1 
hash_user_map[table1.hash] = table1.user; 

아니오 표 2

에서 해시와 모든 금이 암호를 통해 이동 테이블에서 해시 것
std::string user = hash_user_map[table2.hash]; 
std::cout << user << ":" << table2.password << "\n; 
+0

그건 아주 멋지고 단순한 접근법입니다. 원래는 해시 맵을 시도했지만 키와 값 데이터 유형을 지정하지 않았다고 생각합니다. 이 구현은 읽기 및 쓰기를 절약하여 시간을 절약 할 수 있다고 생각합니다. 나는 그 한 발을 줄 것이고 당신에게 알려줄 것이다! – Signus

+0

bash에서 연관된 배열을 사용하여 간단한 방법으로 작성하고 게시했습니다. 체크 아웃하십시오! – Signus