Showing posts with label Mac OSX. Show all posts
Showing posts with label Mac OSX. Show all posts

Wednesday, April 18, 2012

SSD Drives and Mac OSX

Good Morning World, I've been missing for a while but its great to be back to normal. Between planning for a wedding, working, and running a consulting business I've been going 100% per hour non stop. Well anyway just want to share my experience on sad and macbook pro. I'm a virtual machine nut thats all i use my macbook pro for now a days for running virtual machines. So i went out bought a 120gb sad intel drive. i must say if you have a mac and no sad drive you a doing your self a huge disservice. i would recommend going with an sad drive. my boot time is a lot faster , as well as compile time for my code I'm loving it.

Tuesday, January 3, 2012

Openbsd PF on Mac OSX Lion

Once Again Happy New Year. I've been playing around with the PF firewall on mac osx lion. I have to say that this is a great feature thats built into Mac OSX Lion that a lot of users do not take advantage of. Many People feel that they don't need a firewall just because they are not running windows which is the biggest mistake anyone could ever make. The PF firewall was originally developed for the Openbsd unix OS. Previous version's of Mac OSX were running the now obsolete ipfw firewall software which was also developed on the Openbsd platform. Well lets get to the topic at hand, This is a quick tutorial on how to setup and configure the PF firewall on Mac OSX Lion. In order to setup and configure PF you must have root or sudo access. Everything you need is located in the /etc/pf.conf file this is the main configuration file that PF reads when carrying out its packet filtering duties, All configuration settings are done in the pf.conf file. Now if you need more information on the pf.conf file and what configuration settings are needed in order to get your firewall up and running type the following command man pf.conf or go to openbsd.org which has excellent documentation as well on the PF firewall. Once you have the pf.conf configured the way you like it its now time to upload the conf file into the pf engine, first we have to make sure that pf has been enabled which can be done with the following command pfctl -e Once the PF has been enabled you can upload your config file to the pf engine using the following command:
pfctl -f /etc/pf.conf.


# pfctl -f /etc/pf.conf Load the pf.conf file
# pfctl -nf /etc/pf.conf Parse the file, but don't load it

# pfctl -sr Show the current ruleset
# pfctl -ss Show the current state table
# pfctl -si Show filter stats and counters
# pfctl -sa Show EVERYTHING it can show


below is a sample of my pf.conf file.


################################
#My PF Wireless Configuration #
################################


#################
#Variables #
#################

wi_if="en1"
loop_if="lo0"

####################################
#Lets get to the Filtering #
####################################


##################################
#Blocking Everything by Default #
##################################
block in all
block out all



###################################
#Selective Traffic #
###################################
pass in quick on $wi_if from any to any
pass out quick on $wi_if from any to any
pass in quick on $wi_if proto icmp
pass out quick on $wi_if proto icmp


As i said before the PF firewall has a lot of cool features just too many to go over in this tutorial. If you want to know more just let these 3 things be your guide man pf.conf google.com or openbsd.org :)

Thursday, July 28, 2011

Upgrading to Mac OSX Lion

For the past month I've been waiting to sink my teeth into Lion (Mac OS X 10.7). Well i finally upgraded, I will say that this was the most difficult upgrade that i have ever experienced with apple. Well lets get to it Here are the following steps that i took in order to upgrade to lion from snow leopard: (Note these steps are not written in stone I'm sure there are better ways of upgrading to lion but these are just the steps that i took in order to make it work)


Step1: Make Sure Please make sure that you backup your system using time machine before you upgrade

Step2: Download Mac OS X Lion from the app store, (Note remember in order to upgrade to Lion you have to be running OS X 10.6.8 ) This update prepares you for your upgrade to Lion

Note: when running the install it will first install mac osx 10.7 and then reboot, and then will install any 3rd party drivers it needed and then reboot for a second time.

Step3: Now this is where i began having issues after running the installer my upgrade keep pausing at -42 minutes remaining, this was so crazy that i had the apple rep take a pic of my screen and send it into apple :) fun stuff, Here is how I over came that issue i had to reset my NVRAM and PRAM (Press and hold the Command-Option-P-R keys.) on my MACBOOK PRO which allowed me to do
a fresh install of Lion and the restored all my applications that i backed up using time machine.

Step4: Have fun and Enjoy Lion :)

Saturday, March 26, 2011

Keeping Mac osx updated via Terminal

For the longest time ive been keeping snow leopard updated using the tradition way by clicking on software update and letting it run from the gui. well one day i decided to sit down and write a python script that takes care of this for me. Im not a python guru so if this code is not to your liking then dont use it. If you see something about my code that might need improving please let me know. well first thing your going to need is the pexpect module which can be downloaded from http://sourceforge.net/projects/pexpect/. After downloading the pexpect module open the terminal and run the following command: tar -xzvf pexpect-2.3.tar.gz. Step2: cd pexpect-2.3 (or whatever version you are using). Step3: run the following command: python setup.py install. Once these steps have been completed you are all set to run the following script.


#!/usr/bin/python
#################################################
#This script keeps my mac osx uptodate with the #
#latest patches and updates #
#written by bsdjedi #
#sept 30, 2010 #
#################################################

from subprocess import call, PIPE, Popen
import pexpect
import getpass

################################
#This function applies updates #
#to your Operating System #
#################################


def software_update():
p = getpass.getpass()
child = pexpect.spawn('sudo softwareupdate -d -i -r')
child.expect('Password:')
child.sendline(p)
child.expect('$')
child.interact()






software_update()

Sunday, March 20, 2011

Moving over from Macports to Brew

Good Afternoon everyone today is a wonderful but also a special day b/c today is my birthday. I cannot believe it either blogging on my birthday lol yes i know im pretty geeked out but thats ok
This is a tutorial on how to move over from Macports over to Brew in Mac OSX. For a long time i have been using Macports which in the beginning was the best thing since slice bread but as with everything time can kill or improve an applications performance (Just in my opinion). Well Enough rambling from me let get to it. Here is how i moved from Macports over to Brew.

First: Uninstall(get rid of) Macports by running the following commands:


1. sudo port -f uninstall installed

2. sudo rm -rf \
/opt/local \
/Applications/DarwinPorts \
/Applications/MacPorts \
/Library/LaunchDaemons/org.macports.* \
/Library/Receipts/DarwinPorts*.pkg \
/Library/Receipts/MacPorts*.pkg \
/Library/StartupItems/DarwinPortsStartup \
/Library/Tcl/darwinports1.0 \
/Library/Tcl/macports1.0 \
~/.macports

ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"

Step 2. Install the Brew OSx Package Installer by running the following command:

ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"


Step 3. Once the installer has finished installing
NOTE: The key files for brew are installed in the /usr/local/bin/brew directory
The /usr/local/Cellar directory contains the files of your installed packages.



Step 4. Ok Now that brew is installed the following is an example on how to install an application using the brew command:


brew install mongodb

==> Downloading http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-1.6.3.tgz
######################################################################## 100.0%
==> Caveats
If this is your first install, automatically load on login with:
cp /usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
cp /usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

Or start it manually:
mongod run --config /usr/local/Cellar/mongodb/1.6.3-x86_64/mongod.conf
==> Summary
/usr/local/Cellar/mongodb/1.6.3-x86_64: 16 files, 83M, built in 2 seconds



Another cool command is the info command within brew check it out:

brew info postgresql

postgresql 9.0.1

http://www.postgresql.org/

Depends on: readline, ossp-uuid
/usr/local/Cellar/postgresql/9.0.1 (1229 files, 25M)

If builds of Postgresl 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:

http://github.com/mxcl/homebrew/issues/issue/2510

To build plpython against a specific Python, set PYTHON prior to brewing:
PYTHON=/usr/local/bin/python brew install postgresql
See:

http://www.postgresql.org/docs/9.0/static/install-procedure.html

If this is your first install, create a database with:
initdb /usr/local/var/postgres

If this is your first install, automatically load on login with:
cp /usr/local/Cellar/postgresql/9.0.1/org.postgresql.postgres.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

If this is an upgrade and you already have the org.postgresql.postgres.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
cp /usr/local/Cellar/postgresql/9.0.1/org.postgresql.postgres.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

Or start manually with:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

And stop with:
pg_ctl -D /usr/local/var/postgres stop -s -m fast

If you want to install the postgres gem, including ARCHFLAGS is recommended:
env ARCHFLAGS="-arch x86_64" gem install pg

To install gems without sudo, see the Homebrew wiki.

http://github.com/mxcl/homebrew/commits/master/Library/Formula/postgresql.rb

NOTE if you need anything additional information about how to use brew run the following command:

brew help

Well thats all from me going to head out and enjoy the rest of my birthday. :)

Saturday, March 12, 2011

How to Convert a dmg over to an iso

This morning i downloaded the RedHat Enterprise linux 6 the 64 bit version, However when i downloaded it i noticed that i was in a .dmg file format which is a file type that runs only on MAC OSX (for those that dont know that is like .exe for windows). After playing around with the command line for like an hour i finally figured out how to convert a .dmg file over to iso from the command line in MAC OSX (snow leopard) but im sure this will work in other versions of MAC OSX. Anyway here are the steps that were taken in order to convert a .dmg over to an .iso file.

1. hdiutil convert /path-to-the-.dmg file/ -format UDTO -o /path-to-whatever you are going to name the .iso file

Example: hdiutil convert /Users/csh11/os_systems/redhat/RHEL_6.0x86_64.dmg -format UDTO -o /Users/csh11/redhat6.iso


2. Once the command has finished running you will see the following file redhat6.iso.cdr now all this means is that the file has been converted over to an dvd image all that needs to be done is rename the file from redhat6.iso.cdr to redhat6.iso


3. All done enjoy your new iso file.

Friday, January 14, 2011

How to reset mac osx password without the installer disk

Good Morning all this is my first post of the new year and im on a quest for knowledge i have a thirst for hunger so be on the look out for more blogging from me well lets get to the matter at hand and good friend of mine needed to recover his admin password for his macbook so i decided to write This quick tutorial on how to reset your Mac OS X password without having to use an installer disc. This procedure works on leopard and snow leopard im not sure about the other releases but give it a try and see what happens. let get to it using the following steps:

1. Power on or restart your Mac.

2. At the chime (or grey screen if your chime is turned off), hold down Command+S on your keyboard to enter single-user mode.

3.This step is optional, but it’s a good idea because it checks the consistency of the hard disk before moving on. At the prompt, type fsck -fy and press Enter/Return. Wait for the checks to complete before going to the next step.

4. Type mount -uw / and press Enter.

5. Type launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist and press Enter.

6. Type ls /Users and press Enter. This lists all of the usernames on the computer – helpful if you don’t know or remember what these are.

7. Type dscl . -passwd /Users/username password and replace “username” with one of the users displayed in the previous step. Replace “password” with a new password of your choice. Press Enter.


8. Type reboot and press Enter.

Thursday, September 23, 2010

Upgrading to python 2.7 on Snowleopard

Well im finally back after a string a events going on in my life. This is a quick tutorial on how to upgrade python on OS X 10 in this case snow leopard but will work with other versions of OS X 10 so enough talking lets get to it.


Step1. Install the version of python that you are going to use for example im going to be using python 2.7 so i did the following:

sudo port install python27


Step2. Once your version of python is installed its not to point to that version by doing the following steps:

1. cd /usr/bin
2. sudo rm python
3. sudo ln -s /opt/local/bin/python2.7 python
4. python -V (Tells you the version of python you are using which in this case im using python 2.7 )


Step3. Enjoy your new version of python :) happy hacking :D

Friday, June 4, 2010

How to lock your screen on snow leopard

Well for the past couple of days my friend and i have been trying to figure out how to lock the screen in snow leopard well mac osx for that matter in general, Well after hours of googling i finally figured it out. check it out.


1. Open Automator (in your Applications folder) and choose Service from the list of templates provided and click the Choose button.


2. In the left hand column under Library, select Utilities.

3. In the second column, drag “Run Shell Script” to the right hand pane.

4. At the top of the right hand pane where you dragged the Run Shell Script action, click on the menu next to “Service receives” and choose “no input”.

5. Copy and paste the following Terminal command into the empty text area of the Run Shell Script action:

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

The entire command should be entered on a single line and note there is a space after “/Menu\”.

6. Choose File–>Save, and give the new service a meaningful name like “Lock Computer” that will appear in the Services menu. Once you’ve done that, you can go to the Services menu (located in the current application menu, next to the Apple menu) and your newly created service should appear there.


7. Next open System Preferences –> Keyboard –> Keyboard Shortcuts and select Services in the left column.

8. Scroll down to the bottom and under the General category, you should see your newly created service listed there. Select it, then Double-click close to the right side of the selected line to reveal a field where you can enter a custom keyboard shortcut. Enter an easy to remember but unique keyboard shortcut (I chose to go with ctrl+option+command+L), and then quit System Preferences.


9. enjoy locking your screen =) yeaaaaaaaaaaaaah booooooooy

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 :)

Tuesday, April 6, 2010

Firewall Settings from the command line in Snow Leopard

Maybe someday you need to shutdown or activate the firewall in your mac, and only have access to the command line, then these are the commands to be used.

To check the current status :

sudo defaults read /Library/Preferences/com.apple.alf globalstate

The result will print one of these numbers;

0 = de-activated

1 = on for specific services

2 = on for essential services

if you want to shut it down :

sudo defaults read /Library/Preferences/com.apple.alf globalstate -int 0

PS. Mac OS X comes with an even more powerful Firewall than the one in the system preferences. Open up the Terminal and type “man ipfw” to learn more about it. ;) enjoy

and to turn on for the specific services :

sudo defaults read /Library/Preferences/com.apple.alf globalstate -int 1

The password requested is your own password, and you have to have administrator access to the mac.

This was tested successfully on 10.6.2 (Snow Leopard).


PS. Mac OS X comes with an even more powerful Firewall than the one in the system preferences. Open up the Terminal and type “man ipfw” to learn more about it. :) enjoy

Friday, February 26, 2010

How to install snow leopard into vmware

I know its been a while since i last posted, just been busy with work and life :). The following tutorial is on how to run mac osx inside of a vmware.

The following items are required to start the hacking process:
- Retail DVD of Mac OS X Snow Leopard (or Leopard)
- VMWare Fusion 2 installed


VMWare Fusion detects the OS based on a checksum for the snow Leopard Installation DVD.

However you can create your own checksums that VMWare Fusion will look for by taking your Snow Leopard image and running the following commands:




Verify you installed VMWare Fusion 2.
Then Open a Terminal window and type the following commands:


sudo bash
cd "/Library/Application Support/VMware Fusion/isoimages"
mkdir original
mv darwin.iso tools-key.pub *.sig original
perl -n -p -e 's/ServerVersion.plist/SystemVersion.plist/g' < original/darwin.iso > darwin.iso
openssl genrsa -out tools-priv.pem 2048
openssl rsa -in tools-priv.pem -pubout -out tools-key.pub
openssl dgst -sha1 -sign tools-priv.pem < darwin.iso > darwin.iso.sig
for A in *.iso ; do openssl dgst -sha1 -sign tools-priv.pem < $A > $A.sig ; done
exit

all done enjoy your new vm of mac osx. also NOTE: if you update vmware fusion you mac osx vm will not work and you will have to go through the hacking process all over again. well im off to breakfast yum :)

Thursday, December 10, 2009

Adding users from the command line in Snow Leopard

This is just a quick tutorial on how to add users from the command line in snow leopard. This command will also work in previous versions of os x. The following commands need to be run as root or with the sudo command.


Creating a new user

dscl / -create /Users/bsdjedi

Create a new user and set the default shell for that user

dscl / -create /Users/bsdjedi UserShell /bin/ksh

Creating a new user and setting the uid as well

dscl / -create /Users/bsdjedi UniqueID 800

Setting the password when creating a user

dscl / -create /Users/bsdjedi PASSWORD

or you can use the tradition unix way and run the following:

passwd bsdjedi


If you would like to give a user admin right run the following command

dscl / -append /Groups/admin GroupMembership bsdjedi


This concludes my tutorial on add users in snow leopard ( os x ) from the command line if need more information just do a man dscl. :)

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...