HTTP Response Times for cipherdyne.org
15 August, 2010


15 August, 2010
05 July, 2008
$ cat sort_len.pl #!/usr/bin/perl -w # # prints out a file sorted by longest lines # # $Id: sort_len.pl 1739 2008-07-05 13:44:31Z mbr $ # use strict; my %url = (); my %len_stats = (); my $mlen = 0; my $mnum = 0; open F, "< $ARGV[0]" or die $!; while (<F>) { my $len = length $_; $url{$len} = $_; $len_stats{$len}++; $mlen = $len if $mlen < $len; $mnum = $len_stats{$len} if $mnum < $len_stats{$len}; } close F; $mlen = length $mlen; $mnum = length $mnum; for my $len (sort {$b <=> $a} keys %url) { printf "[len: %${mlen}d, tot: %${mnum}d] %s", $len, $len_stats{$len}, $url{$len}; } exit 0;To illustrate how it works, below is the output of the sort_len.pl script used against itself. Note that at the top of the output the more interesting code appears whereas the most uninteresting code (such as blank lines and lines that contain closing "}" characters) are summarized away at the bottom:
$ ./sort_len.pl sort_len.pl [len: 51, tot: 1] # $Id: sort_len.pl 1739 2008-07-05 13:44:31Z mbr $ [len: 50, tot: 1] printf "[len: %${mlen}d, tot: %${mnum}d] %s", [len: 48, tot: 1] $len, $len_stats{$len}, $url{$len}; [len: 44, tot: 1] # prints out a file sorted by longest lines [len: 43, tot: 1] for my $len (sort {$b <=> $a} keys %url) { [len: 37, tot: 1] if $mnum < $len_stats{$len}; [len: 34, tot: 1] $mlen = $len if $mlen < $len; [len: 32, tot: 1] open F, "< $ARGV[0]" or die $!; [len: 29, tot: 1] $mnum = $len_stats{$len} [len: 25, tot: 1] my $len = length $_; [len: 24, tot: 1] $len_stats{$len}++; [len: 22, tot: 2] $mnum = length $mnum; [len: 21, tot: 1] $url{$len} = $_; [len: 20, tot: 2] my %len_stats = (); [len: 19, tot: 1] #!/usr/bin/perl -w [len: 14, tot: 3] while (<F>) { [len: 12, tot: 1] use strict; [len: 9, tot: 1] close F; [len: 8, tot: 1] exit 0; [len: 2, tot: 5] } [len: 1, tot: 6]Now, let's execute the sort_len.pl script against the trac_access_log file and look at one of the longest web requests. (The sort_len.pl script was able to reduce the 12,000,000 web requests in my Trac logs to a total of 610 interesting lines.) This particular request is 888 characters long, but there were some other similar suspicious requests that had over 4,000 characters that are not displayed for brevity:
[len: 888, tot: 1] 195.250.160.37 - - [02/Mar/2008:00:30:17
-0500] "GET /trac/fwsnort/anydiff?new_path=%2Ffwsnort%2Ftags%2Ffwsnort
-1.0.3%2Fsnort_rules%2Fweb-cgi.rules&old_path=%2Ffwsnort%2Ftags%2F
fwsnort-1.0.3%2Fsnort_rules%2Fweb-cgi.rules&new_rev=http%3A%2F%2Ff
1234.info%2Fnew5%2Findex.html%0Ahttp%3A%2F%2Fa1234.info%2Fnew4%2F
map.html%0Ahttp%3A%2F%2Ff1234.info%2Fnew2%2Findex.html%0Ahttp%3A%2F
%2Fs1234.info%2Fnew9%2Findex.html%0Ahttp%3A%2F%2Ff1234.info%2Fnew6%2F
map.html%0A&old_rev=http%3A%2F%2Ff1234.info%2Fnew5%2Findex.html%0Ahttp
%3A%2F%2Fa1234.info%2Fnew4%2Fmap.html%0Ahttp%3A%2F%2Ff1234.info%2Fnew2
%2Findex.html%0Ahttp%3A%2F%2Fs1234.info%2Fnew9%2Findex.html%0Ahttp%3A
%2F%2Ff1234.info%2Fnew6%2Fmap.html%0A HTTP/1.1" 200 3683 "-"
"User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR
1.1.4322; .NET CLR 2.0.50727; InfoPath.2)"
My guess is that the above request is a bot that is trying to do one of two
things: 1) force Trac to accept the content in the request (which contains
a bunch of links to pages like "http://f1234.info/new/index.html" - note that
I altered the domain so as to not legitimize the original content) and
display it for other Trac users or to search engines, or 2) force Trac
itself to generate web requests to the provided links (perhaps as a way to increase
hit or referrer counts from domains - like mine - that are not affiliated with the
spammer). Either way, the strategy is flawed because the request is against the
Trac "anydiff" interface which doesn't accept user content other than svn revision
numbers, and (at least in Trac-0.10.4) such requests do not cause Trac to issue any
external DNS or web requests - I verified this with tcpdump on my Trac server after
generating similar requests against it.
17 February, 2008
" Transparent editing of gpg encrypted files.
" By Wouter Hanegraaff <wouter@blub.net>
augroup encrypted
au!
" First make sure nothing is written to ~/.viminfo while editing
" an encrypted file.
autocmd BufReadPre,FileReadPre *.gpg set viminfo=
" We don't want a swap file, as it writes unencrypted data to disk
autocmd BufReadPre,FileReadPre *.gpg set noswapfile
" Switch to binary mode to read the encrypted file
autocmd BufReadPre,FileReadPre *.gpg set bin
autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
" Switch to normal mode for editing
autocmd BufReadPost,FileReadPost *.gpg set nobin
autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
" Convert all text to encrypted text before writing
autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-recipient-self -ae 2>/dev/null
" Undo the encryption so we are back in the normal text, directly
" after the file has been written.
autocmd BufWritePost,FileWritePost *.gpg u
You can combine this vim tweak with gpgdir to
maintain recursively encrypted directories, and just edit the files directly. For
example, the following sequence of commands shows the creation of an encrypted
file and how vim then interfaces with GnuPG to allow transparent editing:
$ cat > somefile
private data
more private data
$ gpg -e somefile
$ wipe somefile
Okay to WIPE 1 regular file ? (Yes/No) yes
Operation finished.
1 file wiped and 0 special files ignored in 0 directories, 0 symlinks removed but not followed, 0 errors occured.
$ ls -l somefile.gpg
-rw-r--r-- 1 mbr mbr 618 2008-02-17 01:52 somefile.gpg
$ vim somefile.gpg
"somefile.gpg" [noeol] 3L, 618C
You need a passphrase to unlock the secret key for
user: "Michael Rash <mbr@cipherdyne.org>"
2048-bit ELG-E key, ID 1234ABCD, created 2007-05-01 (main key ID ABCD1234)
Enter passphrase:
<apply edits now, and hit :wq >
$ ls -l somefile.gpg
-rw-r--r-- 1 mbr mbr 932 2008-02-17 01:55 somefile.gpg
As you can see from the output above, the file was modified (and the original
file somefile was deleted using wipe).
15 February, 2008
$ trac-admin /path/to/trac_directory permission remove anonymous
TICKET_CREATE TICKET_MODIFY TICKET_VIEW ROADMAP_VIEW REPORT_VIEW
MILESTONE_VIEW REPORT_SQL_VIEW WIKI_CREATE WIKI_MODIFY WIKI_VIEW
Also, you will need to set the default_handler variable in the conf/trac.ini
file to BrowserModule instead of WikiModule. Using the above command, the Trac
navigation bar only includes the Timeline, Browse Source, and Search features as seen
here, and this is a valuable configuration
for small open source projects. However, if you would like additional functionality in Trac to
be enabled for the Cipherdyne projects please email me; perhaps there are benefits here that
would justify the change.