• Blog
  • About Esrun
  • Blackhat SEO Scripts
  • Contact

Lighttpd + PHP on the iPhone

Exact steps to get Lighttpd and PHP running on the iPhone..

1) Jail break the iPhone using QuickPwn
2) Open installer.app on the iPhone and installed “Unix subsystem”
3) Find the iPhones IP address in the wifi config area and SSH into the iPhone using the username root and password alpine
4) In your ssh session type: apt-get install php
5) In your ssh session type: mkdir /htdocs/
6) In your ssh session type: mkdir /htdocs/log/
7) In your ssh session type: chmod 777 /htdocs/log/
8 ) In your ssh session type: apt-get install lighttpd
9) In your ssh session type: mkdir /etc/lighttpd/
10) In your ssh session type: nano /etc/lighttpd/lighttpd.conf
11) Copy this into the SSH session:

include "mod_fastcgi.conf"
server.document-root = "/htdocs/"
server.port = 8080

#server.username = "_sshd"

#server.groupname = "_sshd"

server.bind                = "localhost"

server.tag ="lighttpd"
server.errorlog            = "/htdocs/log/error.log"

accesslog.filename         = "/htdocs/log/access.log"
server.modules              = (

"mod_access",

"mod_accesslog",

"mod_fastcgi",

"mod_rewrite",

"mod_auth",

"mod_fastcgi"

)
index-file.names = ( "index.html", "index.php" )

12) Hit ctrl + o (the letter) to save the file then ctrl + x (the letter) to exit nano editor

Note) I commented out the username and groupname in the above config file so that lighttpd could run as root which is necessary for our future scripts which need to access restricted files on the phone.

13) In your ssh session type: nano /etc/lighttpd/mod_fastcgi.conf

14) Copy this into the SSH session:

fastcgi.server = ( ".php" =>

( "localhost" =>

(

"bin-path" => "/usr/bin/php-cgi",

"socket" => "/tmp/php.socket"

)

)

)

15) Hit ctrl + o (the letter) to save the file then ctrl + x (the letter) to exit nano editor

16) In your ssh session type: lighttpd -f /etc/lighttpd/lighttpd.conf

17) In your ssh session type: nano /htdocs/index.php

18) In your session write “test” and hit ctrl + o (the letter) and ctrl + x (the letter)

17) Open safari on the iphone, goto http://localhost:8080 and you should see:

That’s using this php script:

<?
echo “Here’s a scrape of an RSS feed:<br />”;
$data = file_get_contents(‘http://www.esrun.co.uk/blog/feed/rss/’);
preg_match_all(“/<title>(.+?)<\/title>/”, $data, $output);
foreach($output[1] as $title){
echo $title.”<br />”;
}

echo “<br /><br />Here’s some uptime data:<br />”;
passthru(“uptime”);
echo “<br /><br />Here’s some shit that’s running:<br />”;
passthru(“ps -x”);
?>

Right now lighttpd has to be manually started, it wont do it automatically.