1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
diff -Naur electricsheep-2.7b12/electricsheep.c electricsheep-2.7~b12+svn20091224/electricsheep.c
--- electricsheep-2.7b12/electricsheep.c 2009-07-09 04:10:05.000000000 -0400
+++ electricsheep-2.7~b12+svn20091224/electricsheep.c 2009-12-24 18:03:01.000000000 -0500
@@ -564,6 +566,12 @@
n++;
}
}
+ if (n < 1) {
+ if (debug) {
+ fprintf(logout, "median rank undefined\n");
+ }
+ return;
+ }
qsort(tms, n, sizeof(int), compare_ints);
if (0 && debug) {
for (i = 0; i < n; i++)
@@ -1915,7 +1923,7 @@
if (-1 == (decoder_pid = fork())) {
perror("decoder fork");
} else if (0 == decoder_pid) {
- char *argv[20];
+ char *argv[25];
int c = 0;
/* child */
snprintf(fps, 24, "%g", prefs.frame_rate);
@@ -1934,6 +1942,7 @@
cleanup_and_exit(1);
}
argv[c++] = "mplayer";
+ argv[c++] = "-nolirc";
argv[c++] = "-cache";
argv[c++] = "8192";
argv[c++] = "-really-quiet";
diff -Naur electricsheep-2.7b12/electricsheep.h electricsheep-2.7~b12+svn20091224/electricsheep.h
--- electricsheep-2.7b12/electricsheep.h 2009-07-09 04:10:05.000000000 -0400
+++ electricsheep-2.7~b12+svn20091224/electricsheep.h 2009-12-24 18:03:01.000000000 -0500
@@ -74,4 +74,4 @@
void init_list_cmd (char *buf);
void get_end_element(void *userData, const char *name);
void character_handler(void *userData, const XML_Char *s, int len);
-char *encry(char *pw);
+char *encry(char *pw, char *nick);
diff -Naur electricsheep-2.7b12/electricsheep-preferences.c electricsheep-2.7~b12+svn20091224/electricsheep-preferences.c
--- electricsheep-2.7b12/electricsheep-preferences.c 2009-07-09 04:10:05.000000000 -0400
+++ electricsheep-2.7~b12+svn20091224/electricsheep-preferences.c 2009-12-24 18:03:01.000000000 -0500
@@ -108,8 +108,9 @@
prefs.password = strdup("");
} else {
char *pw = (char*)gtk_entry_get_text(password_entry);
+ pw = strdup(pw);
if (strcmp(pw, pw_marker))
- prefs.password = encry(pw);
+ prefs.password = encry(pw, prefs.nick);
}
prefs.video_driver = (char*)gtk_entry_get_text(video_driver_entry);
prefs.frame_rate = gtk_spin_button_get_value(frame_rate_spin);
@@ -207,72 +208,72 @@
void get_widgets(GladeXML *xml) {
title_label = (GtkLabel *) glade_xml_get_widget(xml, "titleLabel");
if (NULL == title_label) {
- fprintf(stderr, "titleLabel not found\n");
+ fprintf(logout, "titleLabel not found\n");
exit(1);
}
test_label = (GtkLabel *) glade_xml_get_widget(xml, "testLabel");
if (NULL == test_label) {
- fprintf(stderr, "testLabel not found\n");
+ fprintf(logout, "testLabel not found\n");
exit(1);
}
test_button = (GtkButton *) glade_xml_get_widget(xml, "testButton");
if (NULL == test_button) {
- fprintf(stderr, "testButton not found\n");
+ fprintf(logout, "testButton not found\n");
exit(1);
}
nick_entry = (GtkEntry *) glade_xml_get_widget(xml, "nickEntry");
if (NULL == nick_entry) {
- fprintf(stderr, "nickEntry not found\n");
+ fprintf(logout, "nickEntry not found\n");
exit(1);
}
url_entry = (GtkEntry *) glade_xml_get_widget(xml, "urlEntry");
if (NULL == url_entry) {
- fprintf(stderr, "urlEntry not found\n");
+ fprintf(logout, "urlEntry not found\n");
exit(1);
}
password_entry = (GtkEntry *) glade_xml_get_widget(xml, "passEntry");
if (NULL == password_entry) {
- fprintf(stderr, "passEntry not found\n");
+ fprintf(logout, "passEntry not found\n");
exit(1);
}
video_driver_entry = (GtkEntry *) glade_xml_get_widget(xml, "vdEntry");
if (NULL == video_driver_entry) {
- fprintf(stderr, "vdEntry not found\n");
+ fprintf(logout, "vdEntry not found\n");
exit(1);
}
frame_rate_spin = (GtkSpinButton *) glade_xml_get_widget(xml, "frameSpin");
if (NULL == frame_rate_spin) {
- fprintf(stderr, "frameSpin not found\n");
+ fprintf(logout, "frameSpin not found\n");
exit(1);
}
nrepeats_spin = (GtkSpinButton *) glade_xml_get_widget(xml, "repeatSpin");
if (NULL == nrepeats_spin) {
- fprintf(stderr, "repeatSpin not found\n");
+ fprintf(logout, "repeatSpin not found\n");
exit(1);
}
cache_spin = (GtkSpinButton *) glade_xml_get_widget(xml, "cacheSpin");
if (NULL == cache_spin) {
- fprintf(stderr, "cacheSpin not found\n");
+ fprintf(logout, "cacheSpin not found\n");
exit(1);
}
no_animation_check = (GtkCheckButton *) glade_xml_get_widget(xml, "noanimCheck");
if (NULL == no_animation_check) {
- fprintf(stderr, "noanimCheck not found\n");
+ fprintf(logout, "noanimCheck not found\n");
exit(1);
}
standalone_check = (GtkCheckButton *) glade_xml_get_widget(xml, "standaloneCheck");
if (NULL == standalone_check) {
- fprintf(stderr, "standaloneCheck not found\n");
+ fprintf(logout, "standaloneCheck not found\n");
exit(1);
}
hide_errors_check = (GtkCheckButton *) glade_xml_get_widget(xml, "hideCheck");
if (NULL == hide_errors_check) {
- fprintf(stderr, "hideCheck not found\n");
+ fprintf(logout, "hideCheck not found\n");
exit(1);
}
save_frames_check = (GtkCheckButton *) glade_xml_get_widget(xml, "saveCheck");
if (NULL == save_frames_check) {
- fprintf(stderr, "saveCheck not found\n");
+ fprintf(logout, "saveCheck not found\n");
exit(1);
}
}
diff -Naur electricsheep-2.7b12/utils.c electricsheep-2.7~b12+svn20091224/utils.c
--- electricsheep-2.7b12/utils.c 2009-07-09 04:10:05.000000000 -0400
+++ electricsheep-2.7~b12+svn20091224/utils.c 2009-12-24 18:03:01.000000000 -0500
@@ -69,19 +70,23 @@
}
}
-char *encry(char *pw) {
+
+char *encry(char *pw, char *nick) {
+ static char *salt = "sh33p";
unsigned char digest[16];
char md5_pw[33];
+ char *pw_salted = malloc(strlen(pw) + strlen(salt) + strlen(nick) + 1);
int i, j;
- md5_buffer(pw, strlen(pw), digest);
+ sprintf(pw_salted, "%s%s%s", pw, salt, nick);
+ md5_buffer(pw_salted, strlen(pw_salted), digest);
for (i = 0, j = 0; i < sizeof(digest); i++) {
char *hex_digits = "0123456789ABCDEF";
-
md5_pw[j++] = hex_digits[digest[i] >> 4];
md5_pw[j++] = hex_digits[digest[i] & 0x0F];
}
md5_pw[j] = 0;
free(pw);
+ free(pw_salted);
return strdup(md5_pw);
}
@@ -97,10 +102,11 @@
free(prefs->url);
prefs->url = strdup(atts[i+1]);
} else if (!strcmp("password", atts[i])) {
- free(prefs->password);
- prefs->password = encry(strdup(atts[i+1]));
+ free(prefs->password);
+ /* assume nick comes before pw in the xml XXX */
+ prefs->password = encry(strdup(atts[i+1]), prefs->nick);
} else if (!strcmp("password_md5", atts[i])) {
- free(prefs->password);
+ free(prefs->password);
prefs->password = strdup(atts[i+1]);
} else if (!strcmp("video_driver", atts[i])) {
free(prefs->video_driver);
@@ -133,7 +139,7 @@
} else if (!strcmp("version", atts[i])) {
// nothing to check
} else {
- fprintf(stderr, "ignoring attribute %s\n", atts[i]);
+ fprintf(logout, "ignoring attribute %s\n", atts[i]);
}
i += 2;
}
@@ -146,7 +152,7 @@
if (argc > 2)
strcpy(rc_file, argv[2]);
else {
- fprintf(stderr,
+ fprintf(logout,
"%s: --preferences option requires a file name argument.\n",
argv[0]);
exit(1);
@@ -155,7 +161,7 @@
}
hom = getenv("HOME");
if (!hom) {
- fprintf(stderr, "%s: HOME envar not defined\n", argv[0]);
+ fprintf(logout, "%s: HOME envar not defined\n", argv[0]);
exit(1);
}
snprintf(rc_file, PATH_MAX, "%s/.electricsheep/preferences.xml", hom);
@@ -281,15 +287,15 @@
int mysystem(char *cmd, char *msg) {
int n;
- if (0) fprintf(stderr, "subprocess; (%s)\n", cmd);
+ if (0) fprintf(logout, "subprocess; (%s)\n", cmd);
if (0 != (n = interruptable_system(cmd))) {
if (SIGINT != n) {
if (!prefs.hide_errors)
- fprintf(stderr, "subprocess error: %s, %d=%d<<8+%d\n",
+ fprintf(logout, "subprocess error: %s, %d=%d<<8+%d\n",
msg, n, n>>8, n&255);
return 1;
}
- fprintf(stderr, "control-c during %s, exiting\n", msg);
+ fprintf(logout, "control-c during %s, exiting\n", msg);
cleanup_and_exit(1);
}
return 0;
@@ -325,7 +331,7 @@
int bytes_read;
void *buff = XML_GetBuffer(parser, XML_BUFF_SIZE);
if (buff == NULL) {
- fprintf(stderr, "unable to allocate buffer.\n");
+ fprintf(logout, "unable to allocate buffer.\n");
exit(1);
}
@@ -334,7 +340,7 @@
break;
if (! XML_ParseBuffer(parser, bytes_read, bytes_read == 0)) {
- fprintf(stderr, "parse error.\n");
+ fprintf(logout, "parse error.\n");
exit(1);
}
}
@@ -441,7 +447,7 @@
void init_curl_cmd(int registration) {
- if (debug) fprintf(stderr, "init_curl_cmd %d\n", registration);
+ if (debug) fprintf(logout, "init_curl_cmd %d\n", registration);
if (prefs.proxy_name) {
snprintf(curl_cmd, MAXBUF, "nice -n %d curl --location --proxy %s",
@@ -472,7 +478,7 @@
}
}
server = dream_server;
- if (debug) fprintf(stderr, "curl_cmd = %s\nserver = %s\n", curl_cmd, server);
+ if (debug) fprintf(logout, "curl_cmd = %s\nserver = %s\n", curl_cmd, server);
}
void init_list_cmd (char *buf) {
|