Skip to content

Commit 11cb0ec

Browse files
committed
Add option to unlimit memory
1 parent d204ddb commit 11cb0ec

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ apt install -y gdbserver strace
3232
-s halt at entry point
3333
-v show debug information
3434
-n disable address space randomization
35+
-u do not limit memory
3536
```
3637

3738
4. Use `gdbpwn.py` to connect to the target IP.

src/arg.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ int arg_opt_m = 0;
1212
int arg_opt_s = 0;
1313
int arg_opt_v = 0;
1414
int arg_opt_n = 0;
15+
int arg_opt_u = 0;
1516

1617
char **arg_execve_argv = NULL;
1718
char *arg_popen = NULL;
@@ -62,14 +63,15 @@ int help()
6263
" -s halt at entry point\n"
6364
" -v show debug information\n"
6465
" -n disable address space randomization\n"
66+
" -u do not limit memory\n"
6567
);
6668
exit(EXIT_FAILURE);
6769
}
6870

6971
int parsing_argv(int argc, char *argv[])
7072
{
7173
int opt;
72-
while ((opt = getopt(argc, argv, "e:p:o:hmsvn")) != -1) {
74+
while ((opt = getopt(argc, argv, "e:p:o:hmsvnu")) != -1) {
7375
switch (opt) {
7476
case 'e':
7577
arg_opt_e = 1;
@@ -97,6 +99,9 @@ int parsing_argv(int argc, char *argv[])
9799
case 'n':
98100
arg_opt_n = 1;
99101
break;
102+
case 'u':
103+
arg_opt_u = 1;
104+
break;
100105
default: /* '?' */
101106
help();
102107
break;

src/debug-server.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define COMMAND_PORT 9545
66
#define GDBSERVER_PORT 9549
77

8-
#define VERSION "1.3.1"
8+
#define VERSION "1.3.2"
99

1010
#define COMMAND_GDB_REGISTER 0x01
1111
#define COMMAND_GDBSERVER_ATTACH 0x02
@@ -54,6 +54,7 @@ extern int arg_opt_m;
5454
extern int arg_opt_s;
5555
extern int arg_opt_v;
5656
extern int arg_opt_n;
57+
extern int arg_opt_u;
5758
extern char **arg_execve_argv;
5859
extern char *arg_popen;
5960
extern int arg_pid;

src/service.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ int start_service(int client_sock)
131131
}
132132
else if(service_pid == 0)
133133
{
134-
limit.rlim_cur = 0x100000000;
135-
limit.rlim_max = 0x100000000;
136-
CHECK(setrlimit(RLIMIT_AS, &limit) != -1);
134+
if(arg_opt_u == 0)
135+
{
136+
limit.rlim_cur = 0x100000000;
137+
limit.rlim_max = 0x100000000;
138+
CHECK(setrlimit(RLIMIT_AS, &limit) != -1);
139+
}
137140

138141
CHECK(sigprocmask(SIG_SETMASK, &old_mask, NULL) != -1);
139142

0 commit comments

Comments
 (0)