X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=grml_tips;h=ce981763b0c7d786250596d8c71a80d41aa88981;hb=7c8c9ce28c299033a71a4a6090885dd51fae48ea;hp=5cc65b01a08f2f2008fe5a3bfcb052d5dc79534e;hpb=ed2e428fca957e0b3d5a32f455e6b9d3209e0e01;p=grml-tips.git diff --git a/grml_tips b/grml_tips index 5cc65b0..ce98176 100644 --- a/grml_tips +++ b/grml_tips @@ -413,13 +413,17 @@ Test sound: Improved grep version: % glark +-- +Grep with highlighting: -glark grep extract-matches +% grep --color=auto ... +% hgrep ... -- -Highlith +Extract matches when grepping: -grepc -hgrep +Usage examples: +% ifconfig | grepc 'inet addr:(.*?)\s' +% ifconfig | glark --extract-matches 'inet addr:(.*?)\s' -- Output text as sound: @@ -700,9 +704,9 @@ Write back the guessed table: Develop, test and use exploit code with the Metasploit Framework: cd /tmp -wget http://www.metasploit.com/tools/framework-2.7-snapshot.tar.gz -unp framework-2.7-snapshot.tar.gz -cd framework* +wget http://framework-mirrors.metasploit.com/msf/downloader/framework-3.0.tar.gz +unp framework-3.0.tar.gz +cd framework-3.0 ./msfcli -- Useful documentation: @@ -855,6 +859,14 @@ local host: remote host: % netcat 192.168.0.1 3333 -- +Reverse Shell via SSH: + +local host (inside the network): +% ssh -NR 1234:localhost:22 remote_host + +remote host (outside the network): +% ssh localhost -p 1234 +-- Remove empty directories with zsh: % rmdir ./**/*(/od) 2> /dev/null @@ -1076,7 +1088,7 @@ EOF See also: http://www.debian.org/releases/stable/i386/apcs04.html.en Avoid all of the above steps - use grml-debootstrap(8) instead! -- -Convert files from Unicode / UTF to ISO: +Convert files from Unicode / UTF-8 to ISO: % iconv -f utf8 -t iso-8859-15 < utffile > isofile @@ -1703,7 +1715,7 @@ GET http://www.google.com HTTP/1.0 [press enter twice] Adjust system for use of qemu with kqemu: Make sure you have all you need: -# apt-get update ; apt-get install qemu grml-kerneladdons +# apt-get update ; apt-get install qemu grml-kerneladdons-$KERNELVERSION Then set up kqemu: @@ -1744,12 +1756,16 @@ Start X and lock console via exiting: % startx 2>~/.xsession-errors &| exit -- -Which process is writing to disk? +Which process is writing to disk and/or causes the disk to spin up? + +First of all use lsof to check what's going on. Does not help? -> # echo 1 > /proc/sys/vm/block_dump -Warning: you must disable syslogd before you do this, or you must -make sure that kernel output is not logged. +The command sets a sysctl to cause the kernel to log all disk +writes. Please notice that there is a lot of data. So please +disable syslogd/syslog-ng before you do this, or you must make +sure that kernel output is not logged. When you're done, disable block dump using: # echo 0 > /proc/sys/vm/block_dump @@ -1757,6 +1773,10 @@ When you're done, disable block dump using: Alternative: laptop-mode-tools provides a tool named lm-profiler (laptop mode profiler) which handles block_dump on its own. + +See: $KERNEL-SOURCE/Documentation/laptop-mode.txt + +Also take a look at event-viewer(8) which is part of grml-debugtools. -- Install initrd via initramfs-tools for currently running kernel: @@ -2057,10 +2077,13 @@ xfs without vol_id: # xfs_admin -l /dev/sda1 reiserfs without vol_id: -# debugreiserfs /dev/sda1 | grep UUID +# debugreiserfs /dev/sda1 | grep -i label + +jfs without vol_id: +# jfs_tune -l /dev/sda1 | grep -i label reiser4 without vol_id: -# debugfs.reiser4 /dev/sda1 | grep uuid +# debugfs.reiser4 /dev/sda1 | grep -i label -- Check filesystem's UUID: @@ -2068,16 +2091,41 @@ generic way: # vol_id -u /dev/sda1 ext2/3 without vol_id: -# dumpe2fs /dev/sda1 | grep UUID +# dumpe2fs /dev/sda1 | grep -i UUID xfs without vol_id: # xfs_admin -u /dev/sda1 reiserfs without vol_id: -# debugreiserfs /dev/sda1 | grep LABEL +# debugreiserfs /dev/sda1 | grep -i UUID reiser4 without vol_id: -# debugfs.reiser4 /dev/sda1 | grep label +# debugfs.reiser4 /dev/sda1 | grep -i UUID +-- +Change a filesystem's LABEL: + +swap: +# mkswap -L $LABEL /dev/sda1 + +ext2/ext3: +# e2label /dev/sda1 $LABEL +# tune2fs -L $LABEL /dev/sda1 + +reiserfs: +# reiserfstune -l $LABEL /dev/sda1 + +jfs: +# jfs_tune -L $LABEL /dev/sda1 + +xfs: +# xfs_admin -L $LABEL /dev/sda1 + +fat/vfat: +# echo 'drive i: file="/dev/sda1"' >> ~/.mtoolsrc +# mlabel -s i:$LABEL + +ntfs: +# ntfslabel $LABEL /dev/sda1 -- Disable pdiffs feature of APT: @@ -2100,7 +2148,7 @@ Restore the backup using unzsplit: More usage examples: man zsplit + man unzsplit -- -Measure network performance using ipserf +Measure network performance using iperf: Server side: % iperf -s -V @@ -2252,6 +2300,12 @@ Download binary codecs for mplayer: # /usr/share/mplayer/scripts/win32codecs.sh +or + +# /usr/share/mplayer/scripts/binary_codecs.sh install + +(depending on the mplayer version you have). + To play encrypted DVDs and if you are living in a country where using libdvdcss code is not illegal can install Debian package libdvdread3 and use the script /usr/share/doc/libdvdread3/install-css.sh. @@ -2362,20 +2416,220 @@ EOF Start dnsmasq finally: # Restart dnsmasq -- -Find out which process(es) cause the disk to spin up: +Display stats about memory allocations performed by a program: -# echo 1 > /proc/sys/vm/block_dump +Usage example for 'ls': -The command sets a sysctl to cause the kernel to log all disk -writes. Please notice that there is a lot of data. +% LD_PRELOAD=/lib/libmemusage.so ls > /dev/null +-- +Use KVM (Kernel-based Virtual Machine for Linux): -See: $KERNEL-SOURCE/Documentation/laptop-mode.txt +Make sure to install the relevant tools: +# apt-get update ; apt-get install kvm +# modprobe kvm -Also take a look at event-viewer(8). +Test it with a minimal system like ttylinux: +# wget http://www.minimalinux.org/ttylinux/packages/bootcd-i386-5.3.iso.gz +# gzip -d bootcd-i386-5.3.iso.gz +# kvm -cdrom bootcd-i386-5.3.iso -- -Display stats about memory allocations performed by a program: +EEPROM data decoding for SDRAM DIMM modules: -Usage example for 'ls': +# modprobe eeprom +# /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl +-- +Set up and use DVB: -% LD_PRELOAD=/lib/libmemusage.so ls > /dev/null +Make sure your device is supported by Linux and running. +See http://www.linuxtv.org/ for more details. + +If the DVB device works on your system (see 'hwinfo --usb' +when using a DVB usb device for example), then make sure you +have the scan util from dvb-utils available: + +# aptitude install dvb-utils + +Then create a channels.conf configuration file: + +% scan /usr/share/doc/dvb-utils/examples/scan/... > ~/.mplayer/channels.conf + +You can find some example configuration files on +your grml system in ~/.channels. Usage example: + +% ln -s ~/.mplayer/channels.conf-AT-graz ~/.mplayer/channels.conf + +Tip: w_scan (see http://free.pages.at/wirbel4vdr/w_scan/index2.html) +might be useful if you do not know the initial configuration +details. +-- +Get the lastest mercurial snapshot: + +Make sure you have the python-dev package available: +# apt-get update ; apt-get install python-dev + +Get and build the source: +% hg clone http://selenic.com/repo/hg mercurial +% cd mercurial +% make local +% export PYTHONPATH=$(pwd) +% export PATH=$PATH:$(pwd) + +now you should have the newest version of mercurial whenever you execute hg. + +To update to the lastest development snapshot, additionally use +the following commands: +% hg pull -u http://hg.intevation.org/mercurial/crew +% make local -- +Configure timezone +================== + +Available bootoptions relevant in live-cd mode: +----------------------------------------------- + +* utc: set UTC, if your system clock is set to UTC (GMT) +* gmt: set UTC, if your system clock is set to UTC (GMT) [like bootoption utc] +* tz=$option: set timezone to corresponding $option, usage example: + tz=Europe/Vienna + +Configuration options relevant on harddisk installation: +-------------------------------------------------------- + +* Use the tzconfig utility to set the local timezone: + + # tzconfig + + which adjusts /etc/timezone and /etc/localtime according + to the provided information. Running: + + # dpkg-reconfigure tzdata + + might be useful as well. + +* /etc/default/rcS: set variable UTC according to your needs, + whether your system clock is set to UTC (UTC='yes') or + not (UTC='no') + +* /etc/localtime: adjust zoneinfo according to your needs: + + # ln -sf /usr/share/zoneinfo/$WHATEVER_YOU_WANT /etc/localtime + + The zoneinfo directory contains the time zone files that were + compiled by zic. The files contain information such as rules + about DST. They allow the kernel to convert UTC UNIX time into + appropriate local dates and times. Use the zdump utility to + print current time and date (in the specified time zone). + +* /etc/adjtime: This file is used e.g. by the adjtimex function, + which can smoothly adjust system time while the system runs + +* If you change the time (using 'date --set ...', ntpdate,...) + it is worth setting also the hardware clock to the correct time: + + # hwclock --systohc [--utc] + + Remember to add the --utc -option if the hardware clock is set + to UTC! + +Still problems? +--------------- + +Check your current settings via: + + cat /etc/timezone + zdump /etc/localtime + echo $TZ + hwclock --show + grep hwclock /etc/runlevel.conf + grep '^UTC' /etc/default/rc + +Further information: +-------------------- + + hwclock(8) tzselect(1) tzconfig(8) + http://www.debian.org/doc/manuals/system-administrator/ch-sysadmin-time.html + http://wiki.debian.org/TimeZoneChanges +-- +Recorder shellscript session using script: + +% script -t 2>~/upgrade.time -a ~/upgrade.script +% scriptreplay ~/upgrade.time ~/upgrade.script +-- +Test UTF-8 capabilities of terminal: + +wget http://melkor.dnp.fmph.uniba.sk/~garabik/debian-utf8/download/UTF-8-demo.txt.gz +zcat UTF-8-demo.txt.gz + +or: + +wget http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt +cat UTF-8-test.txt +-- +UTF-8 at grml / some general information regarding Unicde/UTF-8: + + http://wiki.grml.org/doku.php?id=utf8 +-- + +This allows one ssh connection attepmt per minute per source ip, with a initial +burst of 10. The available burst is like a counter which is initialised with +10. Every connection attempt decrements the counter, and every minute where the +connection limit of one per minute is not overstepped the counter is +incremented by one. If the burst counter is exhausted the real rate limit +comes into play. This gives you 11 connectionattepmts in the first minute +before blocked for 10minutes. After 10 minutes block the game restarts. + +Hint: you could set the burst value to 5 and the block time to only 5 minutes +to achive the same average connection rate but with halve the block time. + +iptables -A inet_in -p tcp --syn --dport 22 -m hashlimit --hashlimit-name ssh \ + --hashlimit 1/minute \ --hashlimit-burst 10 --hashlimit-mode srcip \ + --hashlimit-htable-expire 600000 -j ACCEPT +iptables -A inet_in -p tcp --dport 22 -m state --state NEW -j REJECT +-- +Tunnel a specific connection via socat: + +On the client: +% socat TCP4-LISTEN:8003 TCP4:gateway:500 + +On the gateway: +# socat TCP4-LISTEN:500,fork TCP4:target:$PORT + +Using localhost:8003 on the client uses the tunnel now. +-- +Set date: + +# date --set=060916102007 + +where the bits are month(2)/day(2)/hour(2)/minute(2)/year(4) + +Set date using a relative date: + +# date -s '+3 mins' + +or + +# date -s '+tomorrow' + +Display a specific relative date: + +# date -d '+5 days -2 hours' + +Don't forget to set hardware clock via: + +# hwlock -w +-- +Booting grml via network / PXE: + +Start grml-terminalserver on a system with network access +and where grml is running: + +# grml-terminalserver + +Then booting your client(s) via PXE should work without +any further work. +-- +Debugging SSL communications: + +% openssl s_client -connect webmail.grml.org:993 + +# ssldump -a -A -H -i eth0