From 97e3422f41d94209577713af4f3a94e97d6c4eda Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Sat, 4 May 1996 07:50:45 +0000 Subject: Initial version imported to CVS (This used to be commit 65968b294351d2612d1bf94236d1fcbf853c494e) --- source3/loadparm.h | 160 ++++++++++++++++++++++++++++ source3/params.h | 45 ++++++++ source3/pcap.h | 35 +++++++ source3/reply.h | 60 +++++++++++ source3/smbpass.h | 50 +++++++++ source3/sockspy.c | 302 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 652 insertions(+) create mode 100644 source3/loadparm.h create mode 100644 source3/params.h create mode 100644 source3/pcap.h create mode 100644 source3/reply.h create mode 100644 source3/smbpass.h create mode 100644 source3/sockspy.c (limited to 'source3') diff --git a/source3/loadparm.h b/source3/loadparm.h new file mode 100644 index 0000000000..513dbcd636 --- /dev/null +++ b/source3/loadparm.h @@ -0,0 +1,160 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + Parameter loading functions + Copyright (C) Karl Auer 1993, 1994 + + Extensively modified by Andrew Tridgell + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + * + * Prototypes etc for loadparm.c. + * + */ +#ifndef _LOADPARM_H +#define _LOADPARM_H + +#include "smb.h" + +extern BOOL lp_file_list_changed(void); +extern void lp_killunused(BOOL (*snumused)(int )); +extern BOOL lp_loaded(void); +extern BOOL lp_snum_ok(int iService); +extern BOOL lp_manglednames(int iService); +extern char *lp_passwordserver(void); +extern char *lp_passwd_program(void); +extern char *lp_passwd_chat(void); +extern char *lp_guestaccount(int iService); +extern char *lp_printcapname(void); +extern char *lp_lockdir(void); +extern char *lp_logfile(void); +extern char *lp_configfile(void); +extern char *lp_smb_passwd_file(void); +extern char *lp_rootdir(void); +extern char *lp_defaultservice(void); +extern char *lp_serverstring(void); +extern char *lp_dfree_command(void); +extern char *lp_msg_command(void); +extern char *lp_workgroup(void); +extern char *lp_domain_controller(void); +extern char *lp_username_map(void); +extern char *lp_hosts_equiv(void); +extern char *lp_logon_script(void); +extern char *lp_magicscript(int iService); +extern char *lp_magicoutput(int iService); +extern char *lp_mangled_map(int iService); +char *volume_label(int snum); +extern int lp_os_level(void); +extern int lp_max_ttl(void); +extern int lp_max_log_size(void); +extern int lp_maxxmit(void); +extern int lp_maxmux(void); +extern int lp_mangledstack(void); +extern BOOL lp_preferred_master(void); +extern BOOL lp_domain_master(void); +extern BOOL lp_domain_logons(void); +extern BOOL lp_getwdcache(void); +extern BOOL lp_use_rhosts(void); +extern BOOL lp_readprediction(void); +extern BOOL lp_readbmpx(void); +extern BOOL lp_readraw(void); +extern BOOL lp_writeraw(void); +extern BOOL lp_null_passwords(void); +extern BOOL lp_strip_dot(void); +extern BOOL lp_encrypted_passwords(void); +extern BOOL lp_syslog_only(void); +extern BOOL lp_browse_list(void); +extern int lp_numservices(void); +extern int lp_keepalive(void); +extern int lp_passwordlevel(void); +extern int lp_security(void); +extern int lp_printing(void); +extern int lp_maxdisksize(void); +extern int lp_lpqcachetime(void); +extern int lp_syslog(void); +extern int lp_deadtime(void); +extern int lp_debuglevel(void); +extern int lp_maxprotocol(void); +extern int lp_maxpacket(void); +extern char *lp_comment(int iService); +extern char *lp_preexec(int iService); +extern char *lp_postexec(int iService); +extern char *lp_rootpreexec(int iService); +extern char *lp_rootpostexec(int iService); +extern char *lp_servicename(int iService); +extern char *lp_pathname(int iService); +extern char *lp_username(int iService); +extern char *lp_invalid_users(int iService); +extern char *lp_valid_users(int iService); +extern char *lp_admin_users(int iService); +extern char *lp_printcommand(int iService); +extern char *lp_lpqcommand(int iService); +extern char *lp_lprmcommand(int iService); +extern char *lp_lppausecommand(int iService); +extern char *lp_lpresumecommand(int iService); +extern char *lp_printername(int iService); +extern char *lp_hostsallow(int iService); +extern char *lp_hostsdeny(int iService); +extern char *lp_dontdescend(int iService); +extern char *lp_force_user(int iService); +extern char *lp_force_group(int iService); +extern char *lp_readlist(int iService); +extern char *lp_writelist(int iService); +extern BOOL lp_alternate_permissions(int iService); +extern BOOL lp_revalidate(int iService); +extern BOOL lp_status(int iService); +extern BOOL lp_hide_dot_files(int iService); +extern BOOL lp_browseable(int iService); +extern BOOL lp_widelinks(int iService); +extern BOOL lp_syncalways(int iService); +extern BOOL lp_readonly(int iService); +extern BOOL lp_no_set_dir(int iService); +extern BOOL lp_guest_ok(int iService); +extern BOOL lp_guest_only(int iService); +extern BOOL lp_print_ok(int iService); +extern BOOL lp_postscript(int iService); +extern BOOL lp_map_hidden(int iService); +extern BOOL lp_map_archive(int iService); +extern BOOL lp_locking(int iService); +extern BOOL lp_strict_locking(int iService); +extern BOOL lp_share_modes(int iService); +extern BOOL lp_onlyuser(int iService); +extern BOOL lp_map_system(int iService); +extern BOOL lp_casesensitive(int iService); +extern BOOL lp_casemangle(int iService); +extern BOOL lp_preservecase(int iService); +extern BOOL lp_shortpreservecase(int iService); +extern BOOL lp_load(char *pszFname,BOOL global_only); +extern void lp_dump(void); +extern int lp_servicenumber(char *pszServiceName); +extern BOOL lp_add_home(char *pszHomename, + int iDefaultService, char *pszHomedir); +extern int lp_add_service(char *service, int iDefaultService); +extern BOOL lp_add_printer(char *pszPrintername, int iDefaultService); +extern BOOL lp_readonly(int iService); +extern int lp_create_mode(int iService); +extern int lp_minprintspace(int iService); +extern int lp_defaultcase(int iService); +extern char lp_magicchar(int iService); +extern int lp_max_connections(int iService); +extern BOOL lp_add_home(char *pservice,int ifrom,char *phome); +extern char *lp_string(char *s); +char *my_workgroup(void); + +#endif + diff --git a/source3/params.h b/source3/params.h new file mode 100644 index 0000000000..253eaa4e7a --- /dev/null +++ b/source3/params.h @@ -0,0 +1,45 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + Parameter loading utilities + Copyright (C) Karl Auer 1993, 1994 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/************************************************************************** +PARAMS.H + +Copyright (C) 1990, 1991, 1992 Karl Auer + +Prototypes and definitions for PARAMS.C. +**************************************************************************/ +#ifndef _PARAMS_H +#define _PARAMS_H + +#include +#include "smb.h" + +typedef BOOL (* PM_PARMFUNC)(char *pszParmName, char *pszParmValue); +typedef BOOL (* PM_SECFUNC)(char *pszSectionName); + +#define PM_NOFILE 1 +#define PM_NOFILENAME 2 +#define PM_FILEERROR 3 + +extern BOOL pm_process(char *pszFileName, PM_SECFUNC sfunc, PM_PARMFUNC pfunc); + +#endif + diff --git a/source3/pcap.h b/source3/pcap.h new file mode 100644 index 0000000000..89ab359af6 --- /dev/null +++ b/source3/pcap.h @@ -0,0 +1,35 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + printcap parsing + Copyright (C) Karl Auer 1993, 1994 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + * + * Prototypes etc for pcap.c. + * + */ +#ifndef _PCAP_H +#define _PCAP_H + +#include "smb.h" + +extern BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname); +extern void pcap_printer_fn(void (*fn)()); + +#endif diff --git a/source3/reply.h b/source3/reply.h new file mode 100644 index 0000000000..f88229436f --- /dev/null +++ b/source3/reply.h @@ -0,0 +1,60 @@ +int reply_special(char *inbuf,char *outbuf); +int reply_corep(char *outbuf); +int reply_coreplus(char *outbuf); +int reply_nt1(char *outbuf); +int reply_lanman1(char *outbuf); +int reply_lanman2(char *outbuf); +int reply_tcon(char *inbuf,char *outbuf); +int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_unknown(char *inbuf,char *outbuf); +int reply_ioctl(char *inbuf,char *outbuf); +int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_chkpth(char *inbuf,char *outbuf); +int reply_getatr(char *inbuf,char *outbuf); +int reply_setatr(char *inbuf,char *outbuf); +int reply_dskattr(char *inbuf,char *outbuf); +int reply_search(char *inbuf,char *outbuf); +int reply_fclose(char *inbuf,char *outbuf); +int reply_open(char *inbuf,char *outbuf); +int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize); +int reply_mknew(char *inbuf,char *outbuf); +int reply_ctemp(char *inbuf,char *outbuf); +int reply_unlink(char *inbuf,char *outbuf); +int reply_readbraw(char *inbuf, char *outbuf); +int reply_lockread(char *inbuf,char *outbuf); +int reply_read(char *inbuf,char *outbuf); +int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_writebraw(char *inbuf,char *outbuf); +int reply_writeunlock(char *inbuf,char *outbuf); +int reply_write(char *inbuf,char *outbuf,int dum1,int dum2); +int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_lseek(char *inbuf,char *outbuf); +int reply_flush(char *inbuf,char *outbuf); +int reply_exit(char *inbuf,char *outbuf); +int reply_close(char *inbuf,char *outbuf); +int reply_writeclose(char *inbuf,char *outbuf); +int reply_lock(char *inbuf,char *outbuf); +int reply_unlock(char *inbuf,char *outbuf); +int reply_tdis(char *inbuf,char *outbuf); +int reply_echo(char *inbuf,char *outbuf); +int reply_printopen(char *inbuf,char *outbuf); +int reply_printclose(char *inbuf,char *outbuf); +int reply_printqueue(char *inbuf,char *outbuf); +int reply_printwrite(char *inbuf,char *outbuf); +int reply_mkdir(char *inbuf,char *outbuf); +int reply_rmdir(char *inbuf,char *outbuf); +int reply_mv(char *inbuf,char *outbuf); +int reply_copy(char *inbuf,char *outbuf); +int reply_setdir(char *inbuf,char *outbuf); +int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize); +int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize); +int reply_writebmpx(char *inbuf,char *outbuf); +int reply_setattrE(char *inbuf,char *outbuf); +int reply_getattrE(char *inbuf,char *outbuf); +int reply_writebs(char *inbuf,char *outbuf); +int reply_sends(char *inbuf,char *outbuf); +int reply_sendstrt(char *inbuf,char *outbuf); +int reply_sendend(char *inbuf,char *outbuf); +int reply_sendtxt(char *inbuf,char *outbuf); +int reply_transs2(char *inbuf,char *outbuf,int length,int bufsize); diff --git a/source3/smbpass.h b/source3/smbpass.h new file mode 100644 index 0000000000..6ddca0b92d --- /dev/null +++ b/source3/smbpass.h @@ -0,0 +1,50 @@ +#ifndef _SMBPASS_H_ +#define _SMBPASS_H_ +/* + Unix SMB/Netbios implementation. + Version 1.9. + SMB parameters and setup + Copyright (C) Jeremy Allison 1995 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +struct smb_passwd { + int smb_userid; + char *smb_name; + unsigned char *smb_passwd; /* Null if no password */ + unsigned char *smb_nt_passwd; /* Null if no password */ + /* Other fields / flags may be added later */ +}; + +/* Return a smb_passwd struct given a user name, 0 if fails. */ +struct smb_passwd *get_smbpwnam(char *user); + +#ifndef uchar +#define uchar unsigned char +#endif + +/* SMB Encryption functions. */ +void str_to_key(unsigned char *str,unsigned char *key); +void E_P16(uchar *p14,uchar *p16); +void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24); +void E_md4hash(uchar *passwd,uchar *p16); +void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); +void SMB_nt_encrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); + +/* Password file lock/unlock routines */ +int pw_file_lock(char *name, int type, int secs); +int pw_file_unlock(int fd); +#endif diff --git a/source3/sockspy.c b/source3/sockspy.c new file mode 100644 index 0000000000..806b737915 --- /dev/null +++ b/source3/sockspy.c @@ -0,0 +1,302 @@ +/* + USAGE + sockspy desthost destservice + +You install this program in /etc/inetd.conf and /etc/services + +For example I have used these entries: + +/etc/services: +spy 8001/tcp spy port + +/etc/inetd.conf: +spy stream tcp nowait tridge /usr/local/smb/sockspy sockspy fjall netbios-ssn + +This means any connection to port 8001 will be redirected to +netbios-ssn on fjall. By playing with these parameters you can easily +spy on most of the tcp protocols. All packets traversing the link will +be captured. + +NOTE: This program is totally unsupported. I haven't used it for 2 +years, and don't intend to fix the obvious bugs/limitations. I will, +however, accept contributed patches - or even a total rewrite :-) +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +int trans_num = 0; + +#ifndef LOGIN +#define LOGIN "/tmp/spy.in" +#endif + +#ifndef LOGOUT +#define LOGOUT "/tmp/spy.out" +#endif + +#ifndef LOGCMD +#define LOGCMD "/tmp/spy.cmd" +#endif + +FILE *cmd = NULL; +FILE *login = NULL; +FILE *logout = NULL; + +#define STREQL(a, b) (strcmp(a, b) == 0) +#define NIL (0) + +char DestHost[256]; /* Remote system to connect to */ +char DestObj[256]; /* Remote object/service to connect to */ + +/* Signal handler for SIGPIPE (write on a disconnected socket) */ +abort() +{ + if (cmd) + { + fprintf(cmd,"writing to disconnected socket!\n"); + fflush(cmd); + } + exit(1); +} + + +main(argc, argv) +int argc; /* # of command line arguments */ +char *argv[]; /* the command line arguments */ +{ + int client, /* Socket connected to client */ + server; /* Socket to use for server */ + + trans_num = 0; +#ifndef NOLOG + login = fopen(LOGIN,"w"); + logout = fopen(LOGOUT,"w"); + cmd = fopen(LOGCMD,"w"); +#endif + + if (cmd) + { + fprintf(cmd,"Started server\n"); + fflush(cmd); + } + + /* Check usage */ + if(argc != 3) + return; + + strcpy(DestHost,argv[1]); + strcpy(DestObj,argv[2]); + + /* Time to attempt the connection */ + server = inet_conn(DestHost, DestObj); + + if( server < 0 ) { + exit(EX_CANTCREAT); + } + + /* Just to make the code more readable */ + client = 0; + + /* We will abort gracefully when the client or remote system + goes away */ + signal(SIGPIPE, abort); + + /* Now just go and move raw data between client and + remote system */ + dowork(client, server); + /* ... NEVER RETURNS ... */ +} + +dowork(client, server) + int client, server; +{ + + /* select(2) masks for client and remote */ + int ClientMask, ServerMask; + + /* Combined ClientMask and ServerMask */ + int ReadMask; + + /* Initialize select(2) masks */ + ClientMask = 1<h_addrtype != AF_INET) + fprintf(cmd,"not inet type\n"); + fflush(cmd); + } + + + /* No host entry, no service entry, or host is not + Internet, error! */ + if( servent == NIL || + hostent == NIL || + hostent->h_addrtype != AF_INET ) + return -1; + + /* Get a socket from the system to use for the connection */ + if( (sock = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) + return -1; + + /* Make sure we start with a clean address structure ... */ + bzero(&addr, sizeof(addr)); + + /* ... then fill in the required fields */ + addr.sin_family = AF_INET; + addr.sin_port = servent->s_port; + bcopy(hostent->h_addr, &addr.sin_addr, hostent->h_length); + + /* Now try to connection to the destination */ + if( connect(sock, &addr, sizeof(addr)) < 0 ) { + /* No go, release the socket, and then return error! */ + close(sock); + return -1; + } + + /* Success. Return the connected socket descriptor */ + if (cmd) + fprintf(cmd,"returning %d\n",sock); + return sock; +} + + -- cgit