<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hacktopia &#187; Scripts</title>
	<atom:link href="http://www.hacktopia.net/wp/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hacktopia.net/wp</link>
	<description>The zen of hacking</description>
	<lastBuildDate>Tue, 15 Jun 2010 17:40:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SDS (Solstice DiskSuite) Replacing a failed disk</title>
		<link>http://www.hacktopia.net/wp/sds-solstice-disksuite-replacing-a-failed-disk/</link>
		<comments>http://www.hacktopia.net/wp/sds-solstice-disksuite-replacing-a-failed-disk/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 22:16:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Soalris X86]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[Solaris 10]]></category>
		<category><![CDATA[Solaris Sparc]]></category>
		<category><![CDATA[Veritas Volume Manager]]></category>

		<guid isPermaLink="false">http://www.hacktopia.net/wp/?p=35</guid>
		<description><![CDATA[1. Detach each submirror ex. metadetach -f d0 d20 d0: submirror d20 is detached 2. Clear each submirror ex. metaclear d20 d20: Concat/Stripe is cleared 3. Delete the db replica on the failed drive (you can find the replica output by issuing metadb command with no arguments): ex. metadb -d c0t2d0s7 4. Remove failed drive. [...]]]></description>
			<content:encoded><![CDATA[<p>1. Detach each submirror</p>
<p>ex.  metadetach -f d0 d20<br />
d0: submirror d20 is detached</p>
<p>2.  Clear each submirror</p>
<p>ex.  metaclear d20<br />
d20: Concat/Stripe is cleared</p>
<p>3.  Delete the db replica on the failed drive (you can find the replica output by issuing metadb command with no arguments):</p>
<p>ex.  metadb -d c0t2d0s7</p>
<p>4.  Remove failed drive. Replace with new drive.</p>
<p>5.  Run the format command and place the correct partition table, using the layout of the non-replaced drive.</p>
<p>6. re-create the metadb replica on the new disk</p>
<p>ex.  metadb -a c0t2d0s7</p>
<p>7. Run metainit for each replaced submirror</p>
<p>ex. metainit d21 1 1 c0t2d0s1<br />
d21: Concat/Stripe is setup</p>
<p>8.  Run metattach for each submirror</p>
<p>ex. metattach d0 d20<br />
d0: submirror d20 is attached</p>
<p>ex. metattach d1 d21<br />
d1: submirror d21 is attached</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hacktopia.net/wp/sds-solstice-disksuite-replacing-a-failed-disk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to quickly (batch) make new /home/dir</title>
		<link>http://www.hacktopia.net/wp/how-to-quickly-batch-make-new-homedir/</link>
		<comments>http://www.hacktopia.net/wp/how-to-quickly-batch-make-new-homedir/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 19:51:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.hacktopia.net/wp/?p=34</guid>
		<description><![CDATA[Say you have a new machine, and it is not on NIS or LDAP, it needs to be really secure and only have local accounts. So you need to make a bunch of local accounts, but you need to leave for lunch in a half hour. Well simply use this short simple script to make [...]]]></description>
			<content:encoded><![CDATA[<p>Say you have a new machine, and it is not on NIS or LDAP, it needs to be really secure and only have local accounts. So you need to make a bunch of local accounts, but you need to leave for lunch in a half hour. Well simply use this short simple script to make them and set the proper permissions in a matter of seconds. Below is a sample script, I suggest calling is something like createuserhomedir.sh. We are assuming that there is a file called users which has all the user&#8217;s name that we want to make in the same directory as the script.</p>
<blockquote><p>#!/bin/sh<br />
mkdir=/bin/mkdir</p>
<p>echo &#8220;echoing users&#8221;<br />
cat ./users<br />
echo &#8220;end echoing users&#8221;<br />
echo &#8220;Making Home Directories&#8221;<br />
for i in  `cat ./users`<br />
do<br />
mkdir /export/home/$i<br />
echo &#8220;Fixing Permissions For $i Home DIR&#8217;s&#8221;<br />
chown -R $i:other  /export/home/$i<br />
done</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.hacktopia.net/wp/how-to-quickly-batch-make-new-homedir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HotWire Sudo file</title>
		<link>http://www.hacktopia.net/wp/hotwire-sudo-file/</link>
		<comments>http://www.hacktopia.net/wp/hotwire-sudo-file/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 20:15:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.hacktopia.net/wp/hotwire-sudo-file/</guid>
		<description><![CDATA[The script below I wrote to edit a sudo file in a production environment. #!/bin/sh ## Written By: BAB ## The purpose of this script is to make it so in a big EMERGENCY ## apps support or other approved body can be given access with out ## paging systems support unnecessarily. Great for hotwiring [...]]]></description>
			<content:encoded><![CDATA[<p>The script below I wrote to edit a sudo file in a production environment.</p>
<blockquote><p>#!/bin/sh<br />
## Written By: BAB</p></blockquote>
<blockquote><p>## The purpose of this script is to make it so in a big EMERGENCY<br />
## apps support or other approved body can be given access with out<br />
## paging systems support unnecessarily.  Great for hotwiring the sudo map!<br />
##<br />
## Script Name: Hot Wire<br />
##<br />
# Edits: changed script so that it will check if you can push to a machine before a username is entered not after the username is asked for. -BAB</p></blockquote>
<blockquote><p>#<br />
#<br />
## variables<br />
DATE=`/usr/bin/date`</p>
<p>echo<br />
echo &#8220;Enter the user names that needs to have FULL access through sudo&#8221;<br />
echo &#8220;user names are entered in the form&#8221;<br />
echo<br />
echo EXAMPLE<br />
echo &#8220;USER NAMES:userone,usertwo,userthree&#8221;<br />
echo<br />
echo &#8220;Then you will be asked to enter a machine.&#8221;<br />
echo &#8221;      Only ONE machine name is allowed.&#8221;<br />
echo &#8220;MACHINE:\c&#8221;<br />
read machine</p>
<p>pushed=`ssh root@$machine grep emergencyacessusers /usr/local/etc/sudoers |wc -l`</p>
<p>if [ $pushed != 1 ]<br />
then<br />
echo &#8220;Not able to push to $machine &#8211; Page Systems for assistance.&#8221;<br />
else</p>
<p>echo &#8220;USERNAMES:\c&#8221;<br />
read usernames</p>
<p>#pushed=`ssh root@$machine grep emergencyacessusers /usr/local/etc/sudoers |wc -l`</p>
<p>#if [ $pushed != 1 ]<br />
#    then<br />
#   echo &#8220;Not able to push to $machine &#8211; Page Systems for assistance.&#8221;<br />
# else</p>
<p>echo<br />
echo   &#8220;ALERT     ALERT     ALERT     ALERT             &#8221;<br />
echo   &#8220;The sudoers hotwire file can only be run once   &#8221;<br />
echo   &#8221;    in a 24 hour period per a machine           &#8221;<br />
echo   &#8220;It resets every day at 9am                     &#8221;</p>
<p>echo &#8220;Are you sure you want to allow    $usernames    to have full Access to machine    $machine&#8221;<br />
echo &#8220;Anything besides yes will Quit!&#8221;<br />
echo<br />
echo &#8220;yes ?:\c&#8221;<br />
read yesno<br />
if [ "$yesno" = "yes" ]<br />
then<br />
echo &#8220;pushing temporary sudo changes&#8221;<br />
ssh root@$machine               &#8220;sed &#8216;/EMERGENCYACCESS/s/emergencyacessusers/$usernames/&#8217;  /usr/local/etc/sudoers &gt; /tmp/tempsudo-local&#8221;  ## cat into temp file so sed does not clober orig file<br />
if [ $? != 0 ]<br />
then<br />
echo &#8220;SUDOERS FILE COULD NOT BE PUSHED, POSSIBLE SERVER IS DOWN  $DATE &#8211; Users:$usernames  &#8211;  Machine:$machine&#8221; &gt;&gt; /tmp/tempsudolog-now<br />
else<br />
ssh root@$machine               &#8220;cat /tmp/tempsudo-local &gt; /usr/local/etc/sudoers&#8221;  ## Replace current list because of how sed works<br />
if [ $? != 0 ]<br />
then<br />
echo &#8220;SUDOERS FILE COULD NOT BE PUSHED, POSSIBLE SERVER IS DOWN $DATE &#8211; Users:$usernames  &#8211;  Machine:$machine&#8221; $DATE &gt;&gt; /tmp/tempsudolog-now<br />
else<br />
ssh root@$machine &#8220;mailx -s &#8216;Hot Wire &#8211; SUDO PUSH&#8217; alert@company.com &lt; /usr/local/etc/sudoers&#8221;<br />
if [ $? != 0 ]<br />
then<br />
echo &#8220;COULD NOT SEND MAIL.  &#8211; $DATE &#8211; Users:$usernames  &#8211;  Machine:$machine&#8221;  &gt;&gt; /tmp/tempsudolog-now<br />
else<br />
echo  &#8220;$DATE &#8211; Users:$usernames  &#8211;  Machine:$machine&#8221;        &gt;&gt;  /tmp/tempsudolog-now<br />
echo &#8220;SUDOERS file pushed successfully&#8221;<br />
fi<br />
fi<br />
fi<br />
cat /tmp/tempsudolog-now &gt;&gt; /opt/scripts/tempsudolog<br />
rm /tmp/tempsudolog-now<br />
else<br />
echo &#8220;EXITED &#8211; ROOT SUDO PUSH ABORTED&#8221;<br />
fi<br />
fi</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.hacktopia.net/wp/hotwire-sudo-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>gather uptime of mulitipule machines</title>
		<link>http://www.hacktopia.net/wp/gather-uptime-of-mulitipule-machines/</link>
		<comments>http://www.hacktopia.net/wp/gather-uptime-of-mulitipule-machines/#comments</comments>
		<pubDate>Sun, 16 Sep 2007 19:44:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.hacktopia.net/wp/?p=4</guid>
		<description><![CDATA[Below is a script that I put together to log into multipliable machines via ssh to grab the uptime of the machine. In this situation the machines are all Solaris of either 8,9,10. There is no reason that this script or any other script that I write can not be used on linux or any [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a script that I put together to log into multipliable machines via ssh to grab the uptime of the machine.  In this situation the machines are all Solaris of either 8,9,10.  There is no reason that this script or any other script that I write can not be used on linux or any other *NIX with out a tiny bit of modification.  I try to put plenty of comments into my scripts so they are easy to understand.</p>
<blockquote><p>#!/bin/sh<br />
# Written By: BAB<br />
#Purpose: To gather the uptime from Unix machiens and present it in a readable fashion in order of uptime<br />
#This is to be run from one central machine becuase that is where the ssh keys are set up from<br />
#Prerequisites: ssh, sort, echo, nawk<br />
#Files Used:uptime-before, and uptime-sorted.  uptime-before is where all the machine names and uptime is stored before they are sorted and up in uptime-sorted<br />
#Example Output: machine_name uptime, each on new line starting with shortest uptime, machines with &lt;24 hours can show up not in their proper location because 17 hours is greater then 12 days!</p>
<p>DATE=`/usr/bin/date`</p>
<p>echo &#8220;&#8221; &gt; uptime-before</p>
<p>echo &#8220;Starting to gather uptime&#8221;</p>
<p>#add additional files with machine names to the end of the cat command below.  The files should have one machine name (host name translatable via DNS) per a line<br />
for server in  `cat /opt/scripts/sudo/sudoserver_list   /opt/scripts/sudo/stagingserver_list   /opt/scripts/sudo/non_sudo_server`<br />
do<br />
uptime=`ssh root@$server uptime   |  nawk &#8216;{print $3}&#8217; `</p>
<p>echo &#8220;$server $uptime&#8221; &gt;&gt;  uptime-before<br />
done<br />
echo &#8220;done  getting uptime&#8221;</p>
<p>echo &#8220;$DATE&#8221; &gt; uptime-sorted<br />
sort  -u   uptime-before  | sort +1  -n    &gt;&gt; uptime-sorted</p>
<p>mailx -s &#8220;Weekly uptime report&#8221;  manager@company.com &lt; /opt/scripts/uptime-sorted</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.hacktopia.net/wp/gather-uptime-of-mulitipule-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to make a back up, encript it using gpg and copy it to a remote site using ssh</title>
		<link>http://www.hacktopia.net/wp/how-to-make-a-back-up-encript-it-using-gpg-and-copy-it-to-a-remote-site-using-ssh/</link>
		<comments>http://www.hacktopia.net/wp/how-to-make-a-back-up-encript-it-using-gpg-and-copy-it-to-a-remote-site-using-ssh/#comments</comments>
		<pubDate>Sun, 16 Sep 2007 19:35:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.hacktopia.net/wp/?p=8</guid>
		<description><![CDATA[Below is a script that I wrote to back up a bunch of files, tar them and then compress them. Why use two different programs, tar and zip, because it is the UNIX way. Use one specialty program to do one thing, and one thing very well. If you put too many features into your [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a script that I wrote to back up a bunch of files, tar them and then compress them.  Why use two different programs, tar and zip, because it is the UNIX way.  Use one specialty program to do one thing, and one thing very well.  If you put too many features into your UNIX programs then they just grow too monstrous and unmanageable like Windows (just a example).</p>
<blockquote><p>#!/bin/bash#Written By: BAB<br />
#The purpose of this script is to back up all directories listed, compress the directories, encript the directories, and send them to a remote site.<br />
#compressioin /bin/bzip2<br />
#archiving    /bin/tar<br />
#encription   /usr/bin/gpg</p></blockquote>
<blockquote><p>ZIP=/bin/bzip2<br />
TAR=/bin/tar<br />
ENCRYPT=/usr/bin/gpg<br />
RM=/usr/bin/rm<br />
DATE=`/usr/bin/date +%m/%d/%Y`</p>
<p>BACKUPDIRS=/home/one /home/two<br />
BACKUPNAME=server-backup$DATE<br />
REMOTESERVER=server.com</p>
<p>REMOTEUSERNAME=username</p>
<p>GPGNAME=my name</p>
<p>echo &#8220;starting backup&#8221;</p>
<p>echo  &#8221;      AKA  tar&#8221;</p>
<p>$TAR -cf $BACKUPNAME.tar $BACKUPDIRS</p>
<p>echo &#8220;Starting zip&#8221;<br />
$ZIP -z $BACKUPNAME.tar</p>
<p>echo &#8220;starting encryption&#8221;<br />
$ENCRYPT &#8211;encrypt &#8211;recipient &#8216;$GPGNAME&#8217; BACKUPNAME.tar</p>
<p>echo &#8220;sending to remote site one&#8221;<br />
scp FILE $REMOTEUSERNAME@REMOTESERVER:~</p>
<p>echo &#8220;doing cleanup&#8221;<br />
$RM $BACKUPNAME.tar.gpg<br />
echo &#8220;cleanup done&#8221;</p>
<p>echo &#8220;Backup Complete!&#8221;</p>
<p>#echo &#8220;Decripting the file&#8221;<br />
#gpg &#8211;output foo.txt &#8211;decrypt foo.txt.gpg</p>
<p>#  echo &#8220;Usage: $0 {-encript -decript}&#8221; &gt;&amp;2<br />
#  exit 1<br />
#  ;;<br />
#esac</p>
<p>#exit 0</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.hacktopia.net/wp/how-to-make-a-back-up-encript-it-using-gpg-and-copy-it-to-a-remote-site-using-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
