Playing around with DD-WRT

I’m currently playing around with my two WL-330GE Access points from asus (see an older posting). Since that posting I was a bit creative using the existing ethernet cabling and ports in the apartment to be able to retire the WiFi bridge without having any cable going through the apartment.

So I decided to use the two access points for something more useful. I’m playing around with dd-wrt to build configurations to use them as WiFi probes (for an IDS), or as Rouge Access Points (for demonstration purposes and to test wireless IDS solutions).  I might compile my own dd-wrt version for the rouge version, there are a few things I miss to build a truly evil device.

I like the size of the devices (very compact) and that you can power them with 5V (you can run them off any USB port, right now the one here is hooked up to the USB port of a printer intended for cameras) the only thing missing to make them perfect would be Power-over-Ethernet and maybe a GSM interface to upload data online.

Fun having a cheap and small device like this with Wifi and ethernet running linux. Provides lots of possibilities and fun.

 

Continue reading

, , , , , , ,

How to make a wonderful cookie dessert in a skillet

A few weeks ago I stumbled across this recipe for making a cookie in a skillet http://www.sophistimom.com/one-pan-skillet-cookie and shared it with a few people because I though it looked cool. My wonderful wife then put “skillet” on our shopping list because she knows I can’t resist cookies, and yesterday we tried out the recipe. It was easy and tasted wonderful :-)

Below are some pics of the treat.

Skillet Cookie

10 Photos

Continue reading

, ,

How to increase Fraps performance with a ramdisk

I recently started playing Battlefield 3 and remembered that I have a Fraps license so I installed it and started recording some stuff. Unsurprisingly the performance made a big dip when I recorded. A glance at my PC told me the harddrive was at fault, probably bringing the whole system down due to IO.

Since my PC has more than enough RAM I decided to set up a 5Gb Ramdisk to see if that helped. It did, when writing the video files to the ramdisk I hardly had any performance hit. Unfortunately 5GB isn’t going to last long while recording 1920×1080 @ 40FPS (a few minutes footage at most).

Here is my little cmd file to create a 5GB ramdisk as drive J: and format it for usage:

Select All Code:
1
2
3
imdisk -d -m J:
imdisk -a -t vm -s 5G -o rw -m J:
format J: /A:64k /V:Ramdisk /FS:NTFS /Q

So my next thought was to see if I could write a script to move files off the ramdisk when they were done being written to by Fraps. This obviously was going to cause IO load … the reason we were having performance issues in the first place, so I was skeptical about if this was going to help any. Especially since I also had to move the files away quick enough so that the drive wouldn’t fill up completely with the next file Fraps was writing. I wrote a little powershell script for this (yeah, a *nix Sysadmin writing scripts in powershell …)

Here is my little powershell script to copy the finished files from my ramdisk to a normal HDD (please excuse  possible ugliness, I’m a powershell noob):

Select All Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$source = "j:\*.avi"
$target_dir = "f:\fraps\movies\"
 
while ($true) {
    $files = gci $source
    foreach ($file in $files){ 
        $srcfile = echo $file.fullname
        $dstfile = echo $file.basename
        if ($srcfile) {
            try {
                move-item "$srcfile" "$target_dir$dstfile.avi" -ea stop
                "$srcfile Moved"
            }
            catch {
                "$srcfile in use, cannot be copied right now"
            }
        }
    }
    sleep 5
}

The last little problem I noticed is that the 5GB ramdrive wasn’t big enough (Fraps seems to create some dummy files and fills them up). Forcing Fraps to make smaller files by toggeling the recording fixed that though -> pressing F9 twice fast will drop a few frames though. I used my Logitech G13 for that, just had a key mapped to press F9 quickly every 60 seconds. The shortest gap I could get working reliably is 50ms.

This all probably sounds awfully complicated, but it works and solves my problem. Fraps is great software, but it would be immensly helpful if you could set the file size in the settings (instead of it defaulting to 4GB). Or, even better, if Fraps could rework their IO system to work more efficiently.

So to sum everything up:
- create ramdrive
- start script that copies files from the ramdrive to a normal HDD
- set fraps to store videos on the ramdrive
- start game, press F9 to start recording and then press the G13 key to toggle the F9 periodically

Continue reading

, , , , ,

Yellowstone and Grand Teton Parks

A few weeks ago we traveled a bit west and visited the Yellowstone and Grand Teton National Parks, I’ve finally gotten around to sorting through the pictures and uploading a few (well, actually a lot).

I didn’t get around to editing and stitching the panorama photos together yet, or doing anything interesting with the GPS data of our hikes yet. If I get that done I’ll probably update this posting.

Continue reading

, ,

rcon.c sorcecode (for linux)

Searching for a linux command line rcon tool can be a bit of a pain: dead links, outdated versions not working anymore, stuff written in php …. yeah. The only version I could find was stuck in a cache of an old webpage. So here is my mirror of the http://www.asyserver.com/~cstrike/rcon.c file that currently gives you a “404, File not found” error. Hopefully this will help anyone trying to find a working version via google and is frustrated with the results. Download, compile, happiness ensured.

http://www.dopefish.de/files/rcon.c

Select All Code:
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*
# This is a simple linux command line utility to execute rcon commands
# Just change the YOUR_PASSWORD_HERE to your rcon password (unless
# you want to enter it every time) and possibly change the default
# IP address from 127.0.0.1 (localhost)
#
# once downloaded on your linux system, compile it with:
#
#   gcc -o rcon rcon.c
#
# note, it should work on non-linux too, but may require changing the 
# socket stuff (i.e. windows will definitely need to add the winsock
# initialization line)
#
# written by [ASY]Zyrain
#
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <string.h>
 
#define DEBUG 0
 
#define SERVERDATA_EXECCOMMAND 2
#define SERVERDATA_AUTH 3
#define SERVERDATA_RESPONSE_VALUE 0
#define SERVERDATA_AUTH_RESPONSE 2
 
int send_rcon(int sock, int id, int command, char *string1, char *string2) {
  int size, ret;
  size = 10+strlen(string1)+strlen(string2);
 
  ret = send(sock,&size,sizeof(int),0);
  if(ret == -1) {
    perror("send() failed:");
    return -1;
  }
  ret = send(sock,&id,sizeof(int),0);
  if(ret == -1) {
    perror("send() failed:");
    return -1;
  }
  ret = send(sock,&command,sizeof(int),0);
  if(ret == -1) {
    perror("send() failed:");
    return -1;
  }
  ret = send(sock,string1,strlen(string1)+1,0);
  if(ret == -1) {
    perror("send() failed:");
    return -1;
  }
  ret = send(sock,string2,strlen(string2)+1,0);
  if(ret == -1) {
    perror("send() failed:");
    return -1;
  }
  if(DEBUG) printf("Sent %d bytes\n",size+4);
  return 0;
}
 
int recv_rcon(int sock, int timeout, int *id, int *command, char *string1,
	      char *string2) {
  struct timeval tv;
  fd_set readfds;
  int size;
  char *ptr;
  int ret;
  char buf[8192];
 
  size=0xDEADBEEF;
  *id=0xDEADBEEF;
  *command=0xDEADBEEF;
  string1[0]=0;
  string2[0]=0;
 
  tv.tv_sec = timeout;
  tv.tv_usec = 0;
 
  FD_ZERO(&readfds);
  FD_SET(sock, &readfds);
 
  /* don't care about writefds and exceptfds: */
  select(sock+1, &readfds, NULL, NULL, &tv);
 
  if (!FD_ISSET(sock, &readfds)) {
    if(DEBUG) { 
      printf("recv timeout\n");
    }
    return -1; // timeout
  }
  if(DEBUG) printf("Got a response\n");
  ret = recv(sock, &size, sizeof(int), 0);
  if(ret == -1) {
    perror("recv() failed:");
    return -1;
  }
  if((size<10) || (size>8192)) {
    printf("Illegal size %d\n",size);
    exit(-1);
  }
  ret = recv(sock, id, sizeof(int),0);
  if(ret == -1) {
    perror("recv() failed:");
    return -1;
  }
  size-=ret;
  ret = recv(sock, command, sizeof(int),0);
  if(ret == -1) {
    perror("recv() failed:");
    return -1;
  }
  size-=ret;
 
  ptr = buf;
  while(size) {
    ret = recv(sock, ptr, size, 0);
    if(ret == -1) {
      perror("recv() failed:");
      return -1;
    }
    size -= ret; 
    ptr += ret;
  }
  buf[8190] = 0;
  buf[8191] = 0;
 
  strncpy(string1, buf, 4095);
  string1[4095] = 0;
  strncpy(string2, buf+strlen(string1)+1, 4095);
 
  return 0;
}
 
/* This is set to 1 when we've been authorized */
int auth = 0;
char string1[4096];
char string2[4096];
 
int process_response(int sock) {
  int ret;
  int id;
  int command;
 
  ret=recv_rcon(sock, 1, &id, &command, string1, string2);
  if(DEBUG) printf("Received = %d : id=%d, command=%d, s1=%s, s2=%s\n",
		   ret, id, command, string1, string2);
  if(ret==-1) {
    return -1;
  }
 
  switch(command) {
  case SERVERDATA_AUTH_RESPONSE:
    switch(id) {
    case 20: 
      auth = 1;
      break;
    case -1:
      printf("Password Refused\n");
      return -1;
    default:
      printf("Bad Auth Response ID = %d\n",id);
      exit(-1);
    };
    break;
  case SERVERDATA_RESPONSE_VALUE:
    printf("%s",string1);
    break;
  default:
    printf("Unexpected command: %d",command);
    break;
  };
}
 
int main(int argc, char **argv)
{
  struct sockaddr_in a;
  int sock;
  int ret, i;
  char password[512]="YOUR_PASSWORD_HERE";
  short port = 27015;
  char address[512] = "127.0.0.1";
 
  int arg;
 
  auth = 0;
 
  if(argc<2)
    {
      printf("Syntax: rcon [-P\"rcon_password\"] [-a127.0.0.1] [-p27015] command\n");
      return 0;
    }
 
  for(arg = 1;arg<argc;arg++) {
    if(argv[arg][0] != '-')
      break; /* done with args */
    switch(argv[arg][1]) {
    case 'a':
      strncpy(address, argv[arg]+2, 512);
      break;
    case 'p':
      port = atoi(argv[arg]+2);
      break;
    case 'P':
      strncpy(password, argv[arg]+2, 512);
      break;
    default:
      fprintf(stderr, "Unknown option -%c\n",argv[arg][1]);
      return 0;
    }
  }
 
  a.sin_family = AF_INET;
  a.sin_addr.s_addr = inet_addr(address);
  a.sin_port = htons(port);
 
  sock = socket(AF_INET, SOCK_STREAM,0); // TCP socket
 
  ret = 0;
  ret = connect(sock,(struct sockaddr *)&a,sizeof(a));
 
  if(ret == -1) {
    perror("connect() failed.");
    return -1;
  } else {
    if(DEBUG) printf("Connected to Server\n");
  }
 
  if(DEBUG) printf("Sending RCON Password\n");
  ret=send_rcon(sock, 20, SERVERDATA_AUTH, password, "");
 
  if(ret == -1) {
    perror("Sending password");
    return -1;
  };
 
  while(auth==0) {
    if(process_response(sock)==-1) {
      printf("Couldn't Authenticate\n");
      exit(-1);
    }
  }
 
  if(DEBUG) printf("Password Accepted\n");
  /* Now we're authorized, send command */
 
  /* built command */
  ret = 0;
  while(arg < argc) {
    if(strlen(argv[arg]) + ret < 4096) {
      strcpy(string1+ret, argv[arg]);
      ret += strlen(argv[arg]);
      string1[ret] = ' ';
      ret++;
      arg++;
    } else {
      fprintf(stderr, "cmd too long to send\n");
      return -1;
    }
  }
  //  string1[ret] = '\n';
  //ret++;
  ret--;
  string1[ret]=0;
 
  if(DEBUG) printf("Sending Command: \"%s\"\n", string1);
 
  ret=send_rcon(sock, 20, SERVERDATA_EXECCOMMAND, string1, "");
 
  if(ret == -1) {
    perror("cmd send");
    return -1;
  }
 
  // process responses until a timeout
  while(process_response(sock) != -1);
 
  return 0;
}

Continue reading

prev posts