// File: NKUSec[P]Rethinking-Honeywords/atk.cpp
// Function: main
int main(int argc, char* argv[])
{
	if (argc != 6)
	{
		printf("atk parameters wrong!\n");
		return 0;
	}

	srand(time(NULL));

	acnt = new Account[LINE_NUM]();

	char prefix[LINE_LEN], cracknum_file[LINE_LEN], res_file[LINE_LEN];
	strcpy(prefix, argv[1]);
	int dotpos = strlen(prefix)-1;
	while (prefix[dotpos] != '_' && dotpos > 0) dotpos--;
	prefix[dotpos] = '\0';
	strcpy(cracknum_file, prefix);
	strcat(cracknum_file, "_cracknum.txt");
	strcpy(res_file, prefix);
	strcat(res_file, "_result.txt");

	int THRESHOLD_X = atoi(argv[4]);
	int THRESHOLD_WRONG = atoi(argv[5]);
	read_honeywords_pr_file(argv[1], argv[2], argv[3], THRESHOLD_X);
	attack(cracknum_file, res_file, THRESHOLD_X, THRESHOLD_WRONG);

	printf("hit:%d, wrong:%d, test size:%d\n", hit_cnt, wrong_cnt, account_size);
	delete acnt;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x7590, %rsp           # imm = 0x7590
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x6, -0x8(%rbp)
je 0x2249
leaq 0x1e0b(%rip), %rdi      # 0x4041
movb $0x0, %al
callq 0x1040
movl $0x0, -0x4(%rbp)
jmp 0x2479
xorl %eax, %eax
movl %eax, %edi
callq 0x10f0
movl %eax, %edi
callq 0x1110
movabsq $0x684ee1800, %rdi      # imm = 0x684EE1800
callq 0x1030
movq %rax, -0x7578(%rbp)
movabsq $0x684ee1800, %rdx      # imm = 0x684EE1800
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x7570(%rbp)
movq %rax, -0x7568(%rbp)
movq -0x7568(%rbp), %rdi
movq %rdi, -0x7580(%rbp)
callq 0x25c0
jmp 0x22a2
movq -0x7570(%rbp), %rcx
movq -0x7580(%rbp), %rax
addq $0x118, %rax            # imm = 0x118
cmpq %rcx, %rax
movq %rax, -0x7568(%rbp)
jne 0x228d
movq -0x7578(%rbp), %rax
movq %rax, 0x4e60(%rip)      # 0x7130
leaq -0x2730(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x1100
leaq -0x2730(%rbp), %rdi
callq 0x1090
subq $0x1, %rax
movl %eax, -0x7554(%rbp)
movslq -0x7554(%rbp), %rax
movsbl -0x2730(%rbp,%rax), %ecx
xorl %eax, %eax
cmpl $0x5f, %ecx
movb %al, -0x7581(%rbp)
je 0x2326
cmpl $0x0, -0x7554(%rbp)
setg %al
movb %al, -0x7581(%rbp)
movb -0x7581(%rbp), %al
testb $0x1, %al
jne 0x2332
jmp 0x236a
movl -0x7554(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7554(%rbp)
jmp 0x22fa
movq -0x7578(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movabsq $0x684ee1800, %rsi      # imm = 0x684EE1800
callq 0x11d0
jmp 0x2485
movslq -0x7554(%rbp), %rax
movb $0x0, -0x2730(%rbp,%rax)
leaq -0x4e40(%rbp), %rdi
leaq -0x2730(%rbp), %rsi
callq 0x1100
leaq -0x4e40(%rbp), %rdi
leaq 0x1cbe(%rip), %rsi      # 0x4058
callq 0x11c0
leaq -0x7550(%rbp), %rdi
leaq -0x2730(%rbp), %rsi
callq 0x1100
leaq -0x7550(%rbp), %rdi
leaq 0x1ca6(%rip), %rsi      # 0x4066
callq 0x11c0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1190
movl %eax, -0x7558(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x1190
movl %eax, -0x755c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movl -0x7558(%rbp), %ecx
callq 0x1360
leaq -0x4e40(%rbp), %rdi
leaq -0x7550(%rbp), %rsi
movl -0x7558(%rbp), %edx
movl -0x755c(%rbp), %ecx
callq 0x1cd0
movl 0x4d0d(%rip), %esi      # 0x7140
movl 0x4d0b(%rip), %edx      # 0x7144
movl 0x4cfd(%rip), %ecx      # 0x713c
leaq 0x1c2c(%rip), %rdi      # 0x4072
movb $0x0, %al
callq 0x1040
movq 0x4cdc(%rip), %rax      # 0x7130
movq %rax, -0x7590(%rbp)
cmpq $0x0, %rax
je 0x2472
movq -0x7590(%rbp), %rdi
movl $0x118, %esi            # imm = 0x118
callq 0x1150
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x7590, %rsp           # imm = 0x7590
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x11b0
nop