// File: mniip[P]sandbox/wakeup.cpp
// Function: kill_session()
void kill_session()
{
	int server = socket(AF_UNIX, SOCK_STREAM, 0);
	if(server < 0)
		panic_errno("socket");
	
	struct sockaddr_un addr;
	memset(&addr, 0, sizeof addr);
	addr.sun_family = AF_UNIX;
	strncpy(addr.sun_path, (conf_sockdir + "/socket_" + ident).c_str(), sizeof addr.sun_path - 1);
	if(connect(server, (struct sockaddr *)&addr, sizeof addr))
	{
		if(errno == ENOENT)
			return;
		int err = errno;
		unlink(("socket_" + std::string(ident)).c_str());
		errno = err;
		panic_errno("connect");
	}

	unlink((conf_sockdir + "/socket_" + ident).c_str());

	struct ucred creds;
	socklen_t len = sizeof creds;
	if(getsockopt(server, SOL_SOCKET, SO_PEERCRED, &creds, &len))
		panic_errno("getsockopt SO_PEERCRED");
	if(kill(creds.pid, SIGTERM))
		panic_errno("kill");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movl $0x1, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0x5120
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jge 0x1514b
leaq -0x29(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x5900
movq -0x210(%rbp), %rdx
leaq 0x7309(%rip), %rsi      # 0x1c3f9
leaq -0x28(%rbp), %rdi
callq 0x72d0
jmp 0x150fb
leaq -0x28(%rbp), %rdi
callq 0x130c0
jmp 0x15106
leaq -0x28(%rbp), %rdi
callq 0x59b8
leaq -0x29(%rbp), %rdi
callq 0x5560
jmp 0x1514b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1513d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x59b8
leaq -0x29(%rbp), %rdi
callq 0x5560
jmp 0x155bf
xorps %xmm0, %xmm0
movups %xmm0, -0x52(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movw $0x1, -0xb0(%rbp)
leaq -0xae(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq 0x1250f(%rip), %rsi     # 0x276a0
leaq 0x7268(%rip), %rdx      # 0x1c400
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x10ec0
movq -0x218(%rbp), %rsi
movq 0x1238f(%rip), %rdx     # 0x27548
leaq -0xd0(%rbp), %rdi
callq 0x13520
jmp 0x151c7
leaq -0xd0(%rbp), %rdi
callq 0x5200
movq -0x220(%rbp), %rdi
movq %rax, %rsi
movl $0x6b, %edx
callq 0x52a0
leaq -0xd0(%rbp), %rdi
callq 0x59b8
leaq -0xf0(%rbp), %rdi
callq 0x59b8
movl -0x4(%rbp), %edi
leaq -0xb0(%rbp), %rsi
movl $0x6e, %edx
callq 0x5410
cmpl $0x0, %eax
je 0x153cb
callq 0x5060
cmpl $0x2, (%rax)
jne 0x15248
jmp 0x155b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x59b8
jmp 0x155bf
callq 0x5060
movl (%rax), %eax
movl %eax, -0xf4(%rbp)
movq 0x122ec(%rip), %rax     # 0x27548
movq %rax, -0x230(%rbp)
leaq -0x139(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x5900
movq -0x230(%rbp), %rsi
movq -0x228(%rbp), %rdx
leaq -0x138(%rbp), %rdi
callq 0x72d0
jmp 0x15292
leaq 0x7168(%rip), %rsi      # 0x1c401
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rdx
callq 0x10fb0
jmp 0x152ae
leaq -0x118(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x5200
movq %rax, %rdi
callq 0x5270
movq -0x248(%rbp), %rdi
callq 0x59b8
leaq -0x138(%rbp), %rdi
callq 0x59b8
leaq -0x139(%rbp), %rdi
callq 0x5560
movl -0xf4(%rbp), %eax
movl %eax, -0x23c(%rbp)
callq 0x5060
movl -0x23c(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x161(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x5900
movq -0x238(%rbp), %rdx
leaq 0x70f5(%rip), %rsi      # 0x1c41c
leaq -0x160(%rbp), %rdi
callq 0x72d0
jmp 0x15335
leaq -0x160(%rbp), %rdi
callq 0x130c0
jmp 0x15343
leaq -0x160(%rbp), %rdi
callq 0x59b8
leaq -0x161(%rbp), %rdi
callq 0x5560
jmp 0x153cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x15383
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x59b8
leaq -0x139(%rbp), %rdi
callq 0x5560
jmp 0x155bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x153ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x59b8
leaq -0x161(%rbp), %rdi
callq 0x5560
jmp 0x155bf
leaq 0x122ce(%rip), %rsi     # 0x276a0
leaq 0x7027(%rip), %rdx      # 0x1c400
leaq -0x1a8(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x10ec0
movq -0x250(%rbp), %rsi
movq 0x1214e(%rip), %rdx     # 0x27548
leaq -0x188(%rbp), %rdi
callq 0x13520
jmp 0x15408
leaq -0x188(%rbp), %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5270
leaq -0x188(%rbp), %rdi
callq 0x59b8
leaq -0x1a8(%rbp), %rdi
callq 0x59b8
movl $0xc, -0x1b8(%rbp)
movl -0x4(%rbp), %edi
movl $0x1, %esi
movl $0x11, %edx
leaq -0x1b4(%rbp), %rcx
leaq -0x1b8(%rbp), %r8
callq 0x53b0
cmpl $0x0, %eax
je 0x15512
leaq -0x1d9(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x5900
movq -0x258(%rbp), %rdx
leaq 0x6f9c(%rip), %rsi      # 0x1c424
leaq -0x1d8(%rbp), %rdi
callq 0x72d0
jmp 0x15496
leaq -0x1d8(%rbp), %rdi
callq 0x130c0
jmp 0x154a4
leaq -0x1d8(%rbp), %rdi
callq 0x59b8
leaq -0x1d9(%rbp), %rdi
callq 0x5560
jmp 0x15512
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x59b8
jmp 0x155bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x15501
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x59b8
leaq -0x1d9(%rbp), %rdi
callq 0x5560
jmp 0x155bf
movl -0x1b4(%rbp), %edi
movl $0xf, %esi
callq 0x5740
cmpl $0x0, %eax
je 0x155b6
leaq -0x201(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x5900
movq -0x260(%rbp), %rdx
leaq 0x6af7(%rip), %rsi      # 0x1c043
leaq -0x200(%rbp), %rdi
callq 0x72d0
jmp 0x1555a
leaq -0x200(%rbp), %rdi
callq 0x130c0
jmp 0x15568
leaq -0x200(%rbp), %rdi
callq 0x59b8
leaq -0x201(%rbp), %rdi
callq 0x5560
jmp 0x155b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x155a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x59b8
leaq -0x201(%rbp), %rdi
callq 0x5560
jmp 0x155bf
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x58f0
nopl (%rax,%rax)