" Make hlsearch work like less(1) set hlsearch nnoremap <ESC>u :nohlsearch<CR> hi Search ctermfg=black ctermbg=white
Wed, 28 Mar 2007Make vim's hlsearch behave like less(1)
Put this in your vimrc.
" Make hlsearch work like less(1) set hlsearch nnoremap <ESC>u :nohlsearch<CR> hi Search ctermfg=black ctermbg=white
Comments: 0 (view comments)
Shortcuts in your shell
I always run across commands I want to run more than once, but don't
necessarily merit an alias in my zshrc file. For these commands, I abuse
environment variables and use them as prefixes.
For instance, I have one command that runs mplayer in a loop, in case the connection drops: while true; do mplayer -cache 48 -prefer-ipv4 http://foo.com/streamthing; doneNormally, I might use !while to re-invoke this command. However, I
have lots of oneliners in my shell history that start with while.
So, let's hack around it:
MPLAYER= while true; do mplayer -cache 48 -prefer-ipv4 http://foo.com/streamthing; doneThis will set the environment variable 'MPLAYER' to an empty string and pass it to the while subshell (and thus mplayer), but since MPLAYER isn't used as an environment variable in mplayer, we won't break anything.
Now, any time I want to rerun this specific command, I can just do
Comments: 0 (view comments)
Tue, 27 Mar 2007Shmoocon in review
This past weekend was Shmoocon. I was on-staff for the event due to my
involvement in Hack or Halo. This was the first time I've been on staff for a
big conference. It was pretty cool, mostly because there's a higher frequency
of interesting people in the staff group than in the general population.
This was my first Shmoocon. It's like Defcon but with less debauchery, more clueful presentations, more interesting people, less disinteresting people etc. Defcon is more about getting plastered, gambling, general debauchery, and using presentations as an excuse not to drink. In short, Shmoocon is better technical conference. I flew out on Tuesday because I wanted to take a full week off of work. wxs and I needed to put more time into the puzzles, so I didn't have to kill time by sleeping or visiting landmarks. Time was spent sleeping, working on puzzles, eating, and playing Mario Kart on wxs's Wii. The conference itself was more or less what I had expected. When I attend conferences, I usually end up spending more time out of the sessions than in them, due to my opinion that lots of talks are super boring. The topic usually sounds neat, but the presentation style sucks or the content is worthless. My favorite part of conferences is the side channel stuff. This year's Shmoocon broke tradition and made the NOC open and availabile to anyone this year. I'm sad I didn't get a chance to go in and find out how they setup the network. They had "Shmoocon Labs" prior to the event which invited staff and attendees to come and set up the network the day prior to the conference. Sweet idea, but crazy (Let's setup a network for 1000 people in less than a day). On to presentations! The Jikto talk was cool in that it was code manifestation of already-known vulnerabilities exposed by AJAX, XSS, and web proxies. The speaker accidentally showed the url where the source code lives when he did 'view source' for a few seconds during a demo. Of course, a fair portion of the room scribbled down the url and downloaded it; oops. My favorite talk was the "No tech hacking" talk. The material was, like Jikto, simply an application of known techniques. In this case, it was social engineering and observation. The style was very engaging. The whole point seemed to be that hacking people is stupid easy because most people have credential and other items visibly on the outside. I went to a talk about using entropy for statistical analysis, but the first 5 minutes of it were *really* slow and I pretty much got the idea of what the presenter was talking about in that time, so I left to find other things to do. Hack or Halo. This year the hack was different. It was security/hack-type puzzles instead of the previous year of "exploit these machines as fast as possible". The puzzles ranged from sudoku to lanman hash cracking to port knocking. We had a total of 22 (ish?) puzzles, and only three went unsolved across all of the players Prior to hack or halo, wxs and I were doing some final checks on the puzzles. We booted the machine and found immediately that none of the vmware instances would start. The folder 'C:\Virtual Machines' was permanently stuck in 'read only' mode. Unchecking 'read only' in the permissions box didn't fix it (it kept resetting to 'read only' again). What now? Zoom back another day, when wxs and I were finishing the puzzles. My spider sense told me to back up the vmware images before shutting down, so I had wxs back them up to his laptop. He copied them over from his laptop after we realized the vmware images on the hack server weren't good anymore. They worked fine. Thank god for backups. Other than that hitch, the hack portion of the competition went off without any problems at all. Whew. I have lots of pictures posted on flickr from the competition, greater Shmoocon, and shenanigans at the parties. As far as conference work goes, working on HoH was pretty great. The other options for working Shmoocon seemed to be NOC or physical security. NOC stuff would've been fun, since it would let you play with the new fancy security network gear being tested or generally using gear I don't have access to on a normal basis. HoH didn't take too much of my time during the con, so it was totally worth it. HoH was awesome, and I'm considering doing it next year. If you weren't there, you missed a great conference.
Comments: 1 (view comments)
Sun, 25 Mar 2007Shmoocon 2007 Update
Hack or Halo went quite well last night. The hack portion went without any glitches what-so-ever. We rock. I'll write up more later.
Comments: 0 (view comments)
Mon, 19 Mar 2007Shmoocon 2007
While Shmoocon doesn't start until Friday, I'm flying out tonight. I haven't
been to DC in 10 years, so I'll probably tourist it up atleast for a few hours.
This week is taking me far away from any work-related activities. I turned off
my pager a few minutes ago, so my vacation has officially begun.
See you in DC.
Comments: 0 (view comments)
Interesting FreeBSD rc.conf network option
In rc.conf, I can put:
ipv4_addrs_bge0="192.168.0.1-254/24 192.168.5.50-100/24"And do /etc/rc.d/netif restart bge0
and we get:
% ifconfig bge0
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=1b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING>
inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
inet6 fe80::20a:e4ff:fe3f:92ee%bge0 prefixlen 64 scopeid 0x1
inet 192.168.0.2 netmask 0xffffffff broadcast 192.168.0.2
inet 192.168.0.3 netmask 0xffffffff broadcast 192.168.0.3
...
inet 192.168.0.253 netmask 0xffffffff broadcast 192.168.0.253
inet 192.168.0.254 netmask 0xffffffff broadcast 192.168.0.254
inet 192.168.5.50 netmask 0xffffff00 broadcast 192.168.5.255
inet 192.168.5.51 netmask 0xffffffff broadcast 192.168.5.51
...
inet 192.168.5.99 netmask 0xffffffff broadcast 192.168.5.99
inet 192.168.5.100 netmask 0xffffffff broadcast 192.168.5.100
ether 00:0a:e4:3f:92:ee
media: Ethernet autoselect (none)
status: no carrier
Neat. That's one way to take an entire subnet.
Comments: 0 (view comments)
Sat, 17 Mar 2007Less bullshit, more graph.
I've been working recently on dynamic, simple graphing. Systems like Cacti
provide useful interfaces, but getting data into it is a pain in the ass.
You have 1500 machines you want in cacti. How do you do it? My take is that you shouldn't ever need to preregister data types or data sources. Have a system that you simply throw data at, and it stores it so you can get a graph of it later. All I need to do, to graph new data, is simply write a script that produces that data and sends it to the collector. The collector is a python cgi script that frontends to rrdtool. It takes all cgi paramters and stores the values with a few exceptions:
Example: kenya(/mnt/rrds/129.21.60.26) % ls C_bytes_per_page.rrd C_pages_inactive.rrd C_cpu_context_switches.rrd C_rfork_calls.rrd ... etc ...All of those rrds are created by simply throwing data at the python cgi script. The source of the data is a script that runs 'vmstat -s' and turns it into key-value pairs. Why are the files prefixed with "C_" ? The data I am feeding in comes from counters, and therefore should be stored as counter datatypes in rrdtool. The 'C_' prefix is a hint that if the variable needs an rrd created for it, that the DS type should be COUNTER. The default without this prefix is GAUGE.
Sample update http request:
Feel free to view the vmstat -s poll script to get a better idea of what this does. I also have another script that will do some scraping on 'netstat -s' in freebsd (probably works in linux too). vmstat -s looks like this: 456846233 cpu context switches 3220655757 device interrupts 17964606 software interrupts ... etc ...It's trivial to turn this into key-value pairs. If this were Cacti (or similar system) I would have to go through every line of vmstat -s and create a new data type/source/thing for each one, then create one per host. Screw that. Keep in mind my experience with Cacti is pretty small - I saw I had to register data sources and graphs and such manually and left it alone after that. Anyway, back at the problem. Now how do I graph it? The interface isn't the best, but we use a cgi script again:
Show me all the machines with 'C_system_calls' graphed over the past 15 minutes:
This kind of system has the feature that you never need to explicitly define data input variables or data input sources - All you need is to hack together a script that can pump out key-value pairs. No documentation to read. No time consumed registering 500 new servers in your graph system.
Comments: 3 (view comments)
Merging multiple svn repositories
Over the past several years, I've used mainly CVS. I tried switching to
subversion, which has been slow-going. To speed that process, I merged all of
my repositories together into one svn repo. I also used cvs2svn.py to convert
everything in cvs to svn, which put everything into /trunk/ in the repository -
not what I wanted. A simple script fixes that:
repo=file:///path/to/repo svn ls $repo/trunk | xargs -I@ -n1 svn mv $repo/trunk/@ $repo/@ I used svn poorly at first - one repository per project. To fix that, I needed to dump all of them (with svnadmin) and load them into a central repository: # svnadmin dump all of my svn repositories repodir="/home/foo for i in $repodir/SVN/*; do echo $i; svnadmin dump $i > $(basename $i).dump done # load all of my dumpped repositories into the new one repo="/home/foo/NEWSVN" svnadmin create $repo for i in *.dump; do proj="$(echo $i | cut -d. -f1)"; svn mkdir -m "mkdir $proj for import" file://$repo/$proj svnadmin load --parent-dir $proj $repo < $i done
Comments: 3 (view comments)
Wed, 07 Mar 2007Splitting large logs
I've started using grok more. I don't have any regular log processing to do, so
any usage is random and not related to previous runs. As such, I'd would really
love it if grok could process faster. Rather than concentrating on a
potentially-dead-end of making grok faster (complex regex patterns are cpu
intensive), I think it'll be easier to make it parallelizable. The first step
towards parallelization of grok is being able to split logs into small pieces,
quickly.
Both FreeBSD's and Linux's (GNU, really) split(1) tool is fairly slow when you want to split by line count. Splitting by byte count is (should be) faster, but that will break logs because the byte boundary probably won't ever align on a log boundary.. I'd prefer both: the speed of byte size splitting and the sanity of line based splitting. To that end, I wrote a small tool to do just that. Yes, there's probably a tool already available that does exactly what I want, but this was only 100 lines of C, so it was quick to write. GNU split's --line-bytes option is mostly what I want, but it's still crap slow. Here's a comparison between my tool and gnu's split, run on the fastest workstation I have access to. My tool runs 4 times faster than gnu split for this task. # Source file is 382 megs, which is tiny. % du -hs access 382M access # (Fast) Split into approximately 20meg chunks while preserving lines. % time ./fastsplit -b 20971520 -p ./split.fast. access real 0m1.260s user 0m0.018s sys 0m1.242s # (GNU) Split into 87000-line chunks, no guarantee on size. % time split -l 87000 access split.normal.. real 0m4.943s user 0m0.395s sys 0m2.440s # (GNU) Split into 20mb (max) chunks, preserve lines. % time split --line-bytes 20971520 access split.normal_bytes. real 0m4.391s user 0m0.001s sys 0m1.779sYou can see that the actual 'system' time is somewhat close (mine wins by 0.4s), but 'real' time is much longer for Linux's split(1).. My solution is really good if you want quickly split logs for parallel processing and you don't really care how many lines there are so much as you get near N-sized chunks. What's the output look like?
Comments: 0 (view comments)
|
Search this siteNavigationMetadataHome About Resume My Code (SVN)ArticlesARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work EfficiencyProjectsfex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scriptsPresentationsYahoo! Hack Day '06 Unix Essentials Vi/Vim EssentialsTag CloudCalendar
FriendsBarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler ShieldsTechnorati |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||