00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
#include "spfquery.h"
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 int main(
int argc,
char *argv[])
00059 {
00060
u_int8_t i = 0;
00061
u_int8_t res = 0;
00062
00063
char *margv = NULL;
00064
char *ip = NULL;
00065
char *address = NULL;
00066
char *helo = NULL;
00067
00068
char *tmp = NULL;
00069
00070
peer_info_t *pinfo = NULL;
00071
00072
if (argc <= 1)
00073 {
00074
SPF_usage();
00075
return(
FALSE);
00076 }
00077
00078
for (i = 1; i < argc; i++)
00079 {
00080 tmp = argv[i];
00081
00082
if (*tmp ==
'-')
00083 {
00084 margv = (tmp + 3);
00085
00086
switch (*(tmp + 1))
00087 {
00088
case 'd' :
00089
confg.
level = atoi(margv);
00090
break;
00091
case 'i' :
00092 ip = strdup(margv);
00093
break;
00094
case 's' :
00095 address = strdup(margv);
00096
break;
00097
case 'h' :
00098 helo = strdup(margv);
00099
break;
00100 }
00101 }
00102 }
00103
00104
if (ip == NULL)
00105 {
00106 printf(
"You need to specify an IP Address to test against\n\n");
00107
SPF_usage();
00108
return(
FALSE);
00109 }
00110
else if (address == NULL)
00111 {
00112 printf(
"You need to specify a from email address\n\n");
00113
SPF_usage();
00114
return(
FALSE);
00115 }
00116
else if (helo == NULL)
00117 {
00118 helo = strdup(
HELO_HOST);
00119 printf(
"You didn't give me a helo host, using (%s)\n", helo);
00120
return(
FALSE);
00121 }
00122
00123
if (
confg.
level >= 1)
00124 {
00125 printf(
"SPF Query v%s - James Couzens <jcouzens@codeshare.ca>\n\n",
00126
SPFQUERY_VERSION);
00127
00128 printf(
"DEBUG: %u\n",
confg.
level);
00129 printf(
"IP address: %s\n", ip);
00130 printf(
"MAIL FROM: %s\n", address);
00131 printf(
"HELO: %s\n", helo);
00132 }
00133
00134
if ((pinfo =
SPF_init(helo, ip, NULL, NULL, NULL,
FALSE,
FALSE)) != NULL)
00135 {
00136
00137
SPF_smtp_helo(pinfo, helo);
00138
00139
00140
SPF_smtp_from(pinfo, address);
00141
00142
00143 pinfo->
RES =
SPF_policy_main(pinfo);
00144
00145
00146 res = pinfo->
RES;
00147
00148
00149 printf(
"%s\n%s\n%s\n",
00150 pinfo->
rs ? pinfo->
rs :
"NULL",
00151 pinfo->
error ? pinfo->
error :
"NULL",
00152 pinfo->
explain ? pinfo->
explain :
"NULL");
00153
00154
00155
SPF_close(pinfo);
00156
00157 }
00158
00159 free(ip);
00160 free(address);
00161 free(helo);
00162
00163
return(
FALSE);
00164 }
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 void SPF_usage()
00179 {
00180 printf(
"Usage:\n");
00181 printf(
"\n");
00182 printf(
"spfquery [dish]\n");
00183 printf(
"\n");
00184 printf(
"-d [x] - DEBUG where x is a number between 1 and 255\n");
00185 printf(
"-i [addr] - IP Address where the fake connection will come from\n");
00186 printf(
"-s [email] - What email address to test with\n");
00187 printf(
"-h [host] - HELO hostname to test with\n");
00188 printf(
"\n");
00189 printf(
"spfquery -i 10.0.0.2 -s jcouzens@6o4.ca -h spftools.net\n");
00190
00191
return;
00192 }
00193
00194