... | ... |
@@ -8,16 +8,16 @@ |
8 | 8 |
#include "libclamav/clamav.h" |
9 | 9 |
#include "libclamav/others.h" |
10 | 10 |
|
11 |
-#define OPTS "p:n:i:H:h?" |
|
11 |
+#define OPTS "e:p:n:N:H:h?" |
|
12 | 12 |
|
13 | 13 |
void usage(char *name) |
14 | 14 |
{ |
15 | 15 |
fprintf(stderr, "USAGE: %s -hHinp?\n", name); |
16 | 16 |
fprintf(stderr, "OPTIONS:\n"); |
17 |
+ fprintf(stderr, " -e [EMAIL]\tYour email address (required)\n"); |
|
17 | 18 |
fprintf(stderr, " -h or -?\tShow the help text\n"); |
18 |
- fprintf(stderr, " -H [HostID]\tAttach a custom HostID to the submission.\n"); |
|
19 |
- fprintf(stderr, " -i [FILE]\tSubmit an \"interesting\" file\n"); |
|
20 | 19 |
fprintf(stderr, " -n [FILE]\tSubmit a false negative (FN)\n"); |
20 |
+ fprintf(stderr, " -N [NAME]\tYour name (required)\n"); |
|
21 | 21 |
fprintf(stderr, " -p [FILE]\tSubmit a fase positive (FP)\n"); |
22 | 22 |
exit(0); |
23 | 23 |
} |
... | ... |
@@ -30,78 +30,70 @@ int main(int argc, char *argv[]) |
30 | 30 |
struct curl_httppost *post=NULL, *last=NULL; |
31 | 31 |
struct curl_slist *slist = NULL; |
32 | 32 |
char *type; |
33 |
- char *hostid=NULL; |
|
33 |
+ char *name=NULL, *email=NULL; |
|
34 | 34 |
struct cl_engine *engine; |
35 | 35 |
|
36 | 36 |
while ((ch = my_getopt(argc, argv, OPTS)) > 0) { |
37 |
- if (ch == 'H') |
|
38 |
- hostid = optarg; |
|
37 |
+ switch (ch) { |
|
38 |
+ case 'e': |
|
39 |
+ email = optarg; |
|
40 |
+ break; |
|
41 |
+ case 'N': |
|
42 |
+ name = optarg; |
|
43 |
+ break; |
|
44 |
+ case 'h': |
|
45 |
+ case '?': |
|
46 |
+ usage(argv[0]); |
|
47 |
+ } |
|
39 | 48 |
} |
40 | 49 |
|
50 |
+ if (!(name) || !(email)) |
|
51 |
+ usage(argv[0]); |
|
52 |
+ |
|
41 | 53 |
/* Reset getopt */ |
42 | 54 |
optind = opterr = 1; |
43 | 55 |
optopt = 0; |
44 | 56 |
optarg = NULL; |
45 | 57 |
|
46 |
- if (!(hostid)) { |
|
47 |
- cl_init(0); |
|
48 |
- engine = cl_engine_new(); |
|
49 |
- if (!(engine)) { |
|
50 |
- fprintf(stderr, "Unable to create new ClamAV engine\n"); |
|
51 |
- return 1; |
|
52 |
- } |
|
53 |
- |
|
54 |
- hostid = engine->cb_stats_get_hostid(engine->stats_data); |
|
55 |
- } |
|
56 |
- |
|
57 | 58 |
curl_global_init(CURL_GLOBAL_ALL); |
58 | 59 |
|
59 | 60 |
curl = curl_easy_init(); |
60 |
- curl_easy_setopt(curl, CURLOPT_URL, "http://stats.clamav.dev:8080/clamav/1/submit/file"); |
|
61 | 61 |
|
62 | 62 |
slist = curl_slist_append(slist, "Expect:"); |
63 | 63 |
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); |
64 | 64 |
|
65 | 65 |
while ((ch = my_getopt(argc, argv, OPTS)) > 0) { |
66 |
- if (ch == 'H') |
|
66 |
+ if (ch == 'p') |
|
67 |
+ curl_easy_setopt(curl, CURLOPT_URL, "http://cgi.clamav.net/sendfp.cgi"); |
|
68 |
+ else if (ch == 'n') |
|
69 |
+ curl_easy_setopt(curl, CURLOPT_URL, "http://cgi.clamav.net/sendmalware.cgi"); |
|
70 |
+ else |
|
67 | 71 |
continue; |
68 | 72 |
|
69 |
- switch (ch) { |
|
70 |
- case 'p': |
|
71 |
- type = "fp"; |
|
72 |
- break; |
|
73 |
- case 'n': |
|
74 |
- type = "fn"; |
|
75 |
- break; |
|
76 |
- case 'i': |
|
77 |
- type = "interesting"; |
|
78 |
- break; |
|
79 |
- case '?': |
|
80 |
- case 'h': |
|
81 |
- default: |
|
82 |
- usage(argv[0]); |
|
83 |
- } |
|
84 |
- |
|
85 | 73 |
if ((post)) |
86 | 74 |
curl_formfree(post); |
87 | 75 |
|
88 | 76 |
post = last = NULL; |
89 | 77 |
|
90 |
- if (curl_formadd(&post, &last, CURLFORM_COPYNAME, "type", CURLFORM_COPYCONTENTS, type, CURLFORM_END)) { |
|
91 |
- fprintf(stderr, "Unable to specify type of file in libcurl form for file %s\n", optarg); |
|
78 |
+ if (curl_formadd(&post, &last, CURLFORM_COPYNAME, "sendername", CURLFORM_COPYCONTENTS, name, CURLFORM_END)) { |
|
79 |
+ fprintf(stderr, "Unable to specify name in libcurl form for file %s\n", optarg); |
|
92 | 80 |
break; |
93 | 81 |
} |
94 | 82 |
|
95 |
- if (curl_formadd(&post, &last, CURLFORM_COPYNAME, "file", CURLFORM_FILE, optarg, CURLFORM_END)) { |
|
96 |
- fprintf(stderr, "Unable to specify file path in libcurl form for file %s\n", optarg); |
|
83 |
+ if (curl_formadd(&post, &last, CURLFORM_COPYNAME, "email", CURLFORM_COPYCONTENTS, email, CURLFORM_END)) { |
|
84 |
+ fprintf(stderr, "Unable to specify email in libcurl form for file %s\n", optarg); |
|
97 | 85 |
break; |
98 | 86 |
} |
99 | 87 |
|
100 |
- if (curl_formadd(&post, &last, CURLFORM_COPYNAME, "hostid", CURLFORM_COPYCONTENTS, hostid, CURLFORM_END)) { |
|
101 |
- fprintf(stderr, "Unable to specify HostID in libcurl form for file %s\n", optarg); |
|
88 |
+ if (curl_formadd(&post, &last, CURLFORM_COPYNAME, "file", CURLFORM_FILE, optarg, CURLFORM_END)) { |
|
89 |
+ fprintf(stderr, "Unable to specify file path in libcurl form for file %s\n", optarg); |
|
102 | 90 |
break; |
103 | 91 |
} |
104 | 92 |
|
93 |
+ curl_formadd(&post, &last, CURLFORM_COPYNAME, "action", CURLFORM_COPYCONTENTS, "submit", CURLFORM_END); |
|
94 |
+ curl_formadd(&post, &last, CURLFORM_COPYNAME, "privacy", CURLFORM_COPYCONTENTS, "yes", CURLFORM_END); |
|
95 |
+ curl_formadd(&post, &last, CURLFORM_COPYNAME, "notify", CURLFORM_COPYCONTENTS, "yes", CURLFORM_END); |
|
96 |
+ |
|
105 | 97 |
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post); |
106 | 98 |
res = curl_easy_perform(curl); |
107 | 99 |
|