Thursday, May 27, 2010

Making my macbook hibernate

This is just a quick guide on how to make your macbook or macbook pro hibernate. Now me personally i dont like to waste my battery life, especially when i'm traveling to different places. Ok enough babbling from me lets get to it. For those that dont know here are the different states of the macbook/macbook pro.

* On – Computer is awake, screen is on, battery is being consumed based on your power settings
* Off – Computer is using no power from the battery
* Sleep – Computer has turned off the screen and has suspended the operating system to RAM (volatile memory).
* Hibernation – Computer has turned off most hardware and has suspended the operating system to the harddrive


When you closed the lib on your macbook/macbook pro it will go to sleep and wake up quickly. However while your laptop is sleeping it is still consuming the battery life.

When the battery reaches a certain low level, the Macbook/macbook pro will automatically switch to hibernation mode and basically shut off so you don’t lose any of your work. Sleep is great for when you’re actively using your computer, but when you want to stretch out battery life for as long as possible, you want to hibernate. Also to note is that it appears that the newer Macbook Pros also write information to the harddrive when sleeping so that when the battery drops to dangerous levels it can jump instantly into hibernation. Apple calls this “Safe Sleep”.


In Terminal/iTerm/etc run the following command to determine your current sleep mode:
pmset -g | grep hibernate

This should return one of the following:

* 0 – Legacy sleep mode. It will save everything to RAM upon sleeping but does not support “Safe Sleep”. Very fast sleep.
* 1 – Legacy “Safe Sleep”. This is the “Safe Sleep”. Everything your laptop goes into sleep, it will save everything to harddisk. Slow on Sleep and Startup.
* 3 – Default. As described above, when sleeping, contents are saved to RAM. When battery runs out, hibernate occurs.
* 5 – Behaves as 1 but applicable only for modern Mac that uses “Secure virtual memory”.
* 7 – Behaves as 3 but applicable only for modern Mac that uses “Secure virtual memory”.

Now edit and save your /Users/username/.bash_profile in most cases, However im a ksh kind of geek so i save my alias in my /Users/unixboy/.kshrc file with the following lines:

alias hibernateon="sudo pmset -a hibernatemode 5"
alias hibernateoff="sudo pmset -a hibernatemode 0"

hibernateon and hibernateoff can be any text you want, you just need to remember what you used


Now you have a handy little command that will let you enable and disable instant hibernation on a whim. Whenever you want your machine to hibernate when you close the lid, just drop to a terminal window and type “hibernateon”. When you’d prefer your laptop to just sleep, type “hibernateoff”.

Sunday, May 16, 2010

Installing the python MySQLdb module on snow leopard

Ive been spending the last 2 nights trying to get the MySQLdb module installed on snow leopard, but i finally got it below are the steps that i took in order to get module installed and working.


1. Install mysql server from the macports tree using the following command:
sudo port install mysql5-server

2. Download a copy of MySQL-python from sourceforge.net at the time of this writing they are up to MySQL-python-1.2.3c1.tar.gz


3. unpack the MySQL-python-1.2.3c1.tar.gz package using the following command:
tar -xzvf MySQL-python-1.2.3c1.tar.gz


4. cd into the MySQL-python-1.2.3c1 directory


5. In the MySQL-python-1.2.3c1 directory there is a file named site.cfg, open that file with you favorite editor (mine being vi :) ) and locate the following line:


# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
mysql_config = /usr/local/bin/mysql_config


if you are unsure where you mysql_config file is located, just do a search on your system using the find command.

6. Once the site.cfg has been edited now you are all set and ready to install the module with the following command:

sudo python setup.py install


7. enjoy :)

Thursday, May 6, 2010

Trouble shooting suse linux startup issues

Well i know its been a while since ive last posted anything. Ive been on a roller coaster called Life. Well im back now with the latest from me. I,ve been playing around alot with opensuse(suse) and this document is just a general guideline for troubleshooting suse (opensuse) system boot issues.


Symptom:
Regardless of the kernel selected to boot (failsafe or default), a kernel panic stops the system from booting.

Error(s):
RAMDISK: Couldn't find a valid RAM disk image starting at 0.
VFS: Cannot open a root device "sda2" or unknown-block(0,0)
Please append a correct"root=" boot option
Kernel panic - not syncing: VFS: Cannot open a root device "sda2" or unknown-block(0,0)

Probable Cause:
A corrupted or missing initrd.

Resolution:

1. Boot Installed System*.
2. Login as root.
3. Verify that the / (root) and /boot (if used) filesystems are mounted. The mount command should supply sufficient information. If not, comparing its output with the contents of /etc/fstab should.
4. Run mkinitrd.
5. Reboot.

Symptom:
The system fails to boot and prompts for the root password.

Error(s):
error on stat() /dev/hdb3: No such file or directory
Failed to open the device'/dev/hdb3' : No such file or directory
fsck.reiserfs /dev/hdb3 failed (status 0x8). Run manually!
fsck failed for at least one filesystem (not /).

Probable cause:
Invalid/etc/fstabentry, /dev/hdb3 is a non-existent device.

Resolution:

1. Enter the root password to enter maintenance mode.
2. Remount the root filesystem as read-write:
mount -o rw,remount /
3. Edit /etc/fstab and remove the non-existent device entry. Comparing the output of fdisk -l may provide additional guidance for the non-existent device.
4. [CTRL]+[D] reboots.

Symptom:
The system simply hangs after POST. The screen is completely blank. The option to Boot Installed System* is not available.

Error(s):
If Rescue System is attempted, and fdisk -l run, no partitions are seen. If parted is used, and check run,Error: Partition doesn't existis returned.

Probable cause:
The MBR has been damaged or corrupted.

Resolution:

1. Boot Installed System*.
2. Login as root.
3. Reinstall GRUB:
grub-install bootdevicepath (e.g. /dev/sda)
4. Reboot.

-or-

1. If Boot Installed System* is unavailable, the most likely probable cause is that the partition table is damaged or corrupt, no recovery is possible unless a previous backup of the partition table is available.

Symptom:
When the system boots, an error message is seen, and the system locks. Sometimes the screen just goes black or the server reboots. Sometimes all that is seen is the grub details screen halted after trying to load the/boot/initrd(see below).

Error(s):
No setup signature found ...
initrd /boot/initrd
[Linux-initrd @ 0x1fc38000, 0x2a7ab8 bytes]

Probable cause:
Damaged or corrupted kernel in/boot.

Resolution:

1. Boot Installed System*.
2. Login as root.
3. Install a valid kernel rpm. This can be had from the selected installation medium (under /suse/arch) or from our website at http://www.novell.com/download (search the patches section for kernel-).
rpm -Uvh --force kernel-type-revision-arch.rpm
4. Reboot.

Symptom:
The system boots up toSystem Boot Control: Running /etc/init.d/boot.local, then gracefully reboots.

Error(s):
None.

Probable cause:
Corrupted or misconfigured boot script.

Resolution:

1. At the GRUB menu, type in
init=/bin/bash
on the Boot Options line.
2. Edit /etc/init.d/boot.local and modify or remove the corrupted or misconfigured line.
3. Reboot.

Symptom:
Once exited from a virtual console, the console is not respawned. The console prompt just blinks.

Error(s):
INIT: no more processes left in this runlevel

Probable cause:
Corrupt or misconfigured/etc/inittab

Resolution:

1. Login as root.
2. Edit /etc/inittab and change any tty configuration(s) from once to respawn.
3. Reboot or pkill -1 init.

Symptom:
The kernel panics after trying to mount the root filesystem.

Error(s):
Waiting for device /dev/sda1 to appear: . ok
rootfs: major=8 minor=1 devn=2049
rootfs: /sys/block/sda/sda1 major=8 minor=1 devn=2049
mount: unknown filesystem type 'swap'
umount: /dev: device is busy
Kernel panic - not syncing: Attempted to kill init!
Kernel panic: VFS: Unable to mount root fs on sda1

Probable cause:
Corrupt or misconfigured/boot/grub/menu.lst.

Resolution:

1. Boot Installed System*.
2. Login as root.
3. Edit /boot/grub/menu.lst.
4. Modify the kernel parameter root= to point to the correct root partition. fdisk -l should provide sufficient guidance to determine the root filesystem.
5. Reboot.

Symptom:
The system boots to the GRUB prompt (grub>).

Error(s):
None.

Probable cause:
Corrupt or missing/boot/grub/menu.lstfile.

Resolution:

1. Boot Installed System* -or- if sufficiently familiar with GRUB, manually boot the system.
2. Login as root.
3. Verify the existence of /boot/grub/menu.lst.
If existing, but misnamed, rename it.
If corrupt, delete it and Repair Installed System** (just the Boot Loader Configuration check should be sufficient).
If missing, Repair Installed System** (just the Boot Loader Configuration check should be sufficient).
4. Reboot.

Symptom:
The system boots, but filesystems are not mounted. Many mount-related errors are seen during boot.

Error(s):
Mostly mount-related error messages are seen during boot.
startproc: mount returned not-zero exit status
startproc: /proc not mounted, failed to mount: No such file or directory failed

Probable cause:
The mount binary is either corrupt or missing.

Resolution:

1. Either Repair Installed System** -or - the following.
2. Boot into rescue mode (Rescue System) from the selected installation medium.
3. Login as root.
4. Manually mount the root filesystem (i.e., mount /dev/sda2 /mnt). fdisk -l should provide sufficient information to determine the correct partition.
5. Copy in a valid mount binary from the Rescue System.
6. Reboot.

Symptom:
The system boots, but login fails.

Error(s):
INIT: no more processes left in this runlevel
INIT: /etc/inittab[xx]: missing action field

Probable cause:
Corrupt or misconfigured/etc/inittab

Resolution:

1. Login as root.
2. Edit /etc/inittab and change any tty configuration(s) to include an action (once or respawn) in the action field (third column).
3. Reboot or pkill -1 init.

Symptom:
The system boots, but only to a GRUB screen, then hangs.

Error(s):
GRUB Hard Disk Error

Probable Cause:
As the full GRUB prompt is not achieved, the problem lies somewhere in GRUB stage1. The /boot/grub/stage1file may be missing or corrupted.

Solution:

1. Boot Installed System*.
2. Login as root.
3. Copy /usr/lib/grub/stage1 to/boot/grub/stage1.
4. Reinstall GRUB:
grub-install bootdevicepath(e.g., /dev/sda).
5. Reboot.

-or-

1. Boot Installed System*.
2. Login as root.
3. Identify the installed version of GRUB:
rpm -q grub
4. Remove the installed version. E.g.,
rpm -ev --nodeps grub-0.97-16.1
5. Reinstall the grub package. This can be had from the selected installation medium (under /suse/arch) or from our website at http://www.novell.com/download (search the patches section for grub).
rpm -Uvh grub-version.rpm.
6. Reinstall GRUB:
grub-install bootdevicepath(e.g.,/dev/sda).

Symptom:
The system either doesn't boot, or boots, but some modules aren't loaded and/or some devices are undetected.

Error(s):
FATAL: Error insertingmodulename(modulepath): Unknown symbol in module, or unknown parameter (see dmesg).
modulename: Unknown symbol symbolname

Probable cause:
Occasionally, when modules are updated, the modules dependency file/lib/modules/kernelversion/modules.depis improperly configured or corrupted prior to updating the initial ramdisk.

Resolution:

1. Boot Installed System*.
2. Login as root.
3. Run depmod to regenerate the modules dependency file.
4. Run mkinitrd to generate a new initial RAM disk image.
5. Reboot.

Symptom:
EVMS is used for the root filesystem. The system doesn't boot, with errors related to finding the root filesystem.

Error(s):
Waiting for device /dev/evms/lvm2/system/root to appear: ... not found

Probable cause:
The initial RAM disk image lacks EVMS support.

Resolution:

1. Boot the rescue system and enter the shell.
2. Probe EVMS information:
echo "probe" | evms -s
3. Query devices:
echo "q:d" | evms -s
4. Query volumes:
echo "q:v" | evms -s
This should display the name your root container.
5. Mount the root filesystem (note the comma in the mount command):
mkdir -p /old
echo "mount:/dev/evms/lvm2/system/root,/old" | evms -s
6. The contents of the old root filesystem should be visible now:
ls -l /old/
7. Enter the environment of the installed system:
chroot /old
8. Generate a new inital RAM disk, with EVMS support:
/sbin/mkinitrd -f evms
9. Exit the environment of the installed system through [CTRL]+[D].
10. Reboot.


Some Extra information:


Boot Installed System is the process of using a SuSE Linux Enterprise Server installation medium to boot the installed system. These are the steps:

1. Boot the system off of the selected installation medium (CD/DVD in most cases). This medium should be the same (or later) revision level as the installed system. I.e., if the installed system is SLES9SP2, the installation medium should be SLES9SP2 or later.
2. At Welcome screen, Installation should be selected in place of Boot from Hard Disk.
3. Select the desired Language.
4. Accept the License Agreement(s) (if prompted).
5. At the Installation Mode screen, select Boot Installed System. On SLES10 and later, click on the [Other] button to see these options.

**Repair Installed System is a process similar to Boot Installed System and provides a more automatic repair process. In some cases, when a broader approach to fixing the issue is needed (sledgehammer rather than scalpel), Repair Installed System is the desired process. These are the steps:

1. Boot the system off of the selected installation medium (CD/DVD in most cases). This medium should be the same (or later) revision level as the installed system. I.e., if the installed system is SLES9SP2, the installation medium should be SLES9SP2 or later.
2. At Welcome screen, Installation should be selected in place of Boot from Hard Disk.
3. Select the desired Language.
4. Accept the License Agreement(s) (if prompted).
5. At the Installation Mode screen, select Repair Installed System. On SLES10 and later, click on the [Other] button to see these options.

Cracking Kerberos Service Tickets (TGS) Using Kerberoasting

As of late I've been spending a lot of time researching and learning different techniques when it comes to attacking Active Directory En...