Active Topics

 


Reply
Thread Tools
Posts: 393 | Thanked: 67 times | Joined on Feb 2010
#1
Does anyone know of any interesting Python or shell scripts for the N900, which have not been integrated into an actual well-known N900 application or tool?

Perhaps some interesting scripts related to networking or penetration testing. Are we free to use any stock shell or Python script on the N900, are the interpreters any different from the ones found on non-ARM (non-mobile) Linux distributions?

Thank you

Last edited by mail_e36; 2010-10-18 at 18:18.
 
hawaii's Avatar
Posts: 1,030 | Thanked: 792 times | Joined on Jun 2009
#2
Python should work straight up, provided you have the libraries.

Your best bet is to just fine regular x86 ones and have somebody, wink wink, port them over for you.
 
Posts: 540 | Thanked: 387 times | Joined on May 2009
#3
Install BASH and coreutils. Anything that is script-based (Python can be compiled as .pyc so beware) should work provided you install the necessary dependencies. BASH, Python, Perl, Ruby should all run fairly well.

Most of the pentesting utilities are written in C and thus you will need the compiled versions. There are script-based interfaces available but most are, well pointless.

As far as python goes, I really like woof.py: http://www.home.unix-ag.org/simon/woof.html

Interesting one-liners here: http://www.commandlinefu.com/commands/browse
 

The Following 2 Users Say Thank You to linuxeventually For This Useful Post:
Posts: 30 | Thanked: 42 times | Joined on Oct 2010 @ Russia
#4
Here is my script that scans bluetooth in a loop and records discovered devices in a sqlite3 database. BT must be powered on before.

The idea is to datamine recorded info later. For example how often do I run twice into the same people in the subway or something. Sometimes phone names are rather funny.

The script may be extended to use obexftp to automatically send a picture to a newly discovered device, but I was unable to initiate transfer with my Razr V3 without pin exchange.

Code:
#!/usr/bin/python

import subprocess
import sqlite3
import time

def collect():
	data = []
	b = subprocess.Popen(['hcitool', 'scan'], stdout=subprocess.PIPE)
	x = b.communicate()[0]
	for l in x.splitlines()[1:]:
		l = l.strip().decode('utf8', 'replace')
		parts = l.split('\t', 1)
		mac, name = parts if len(parts)==2 else (l, '')
		data.append((mac, name))

	return data

conn = sqlite3.connect('bt.sqlite3')
cur = conn.cursor()

cur.execute('CREATE TABLE IF NOT EXISTS bt (date INTEGER, mac TEXT, name TEXT)')
conn.commit()

while 1:
	print 'collecting'
	devs = collect()
	for m,n in devs:
		print m, n
	t = int(time.time())
	cur.executemany('INSERT INTO bt VALUES (?,?,?)',
		 map(lambda (m,n): (t,m,n), devs))
	conn.commit()
	time.sleep(10)
 

The Following 7 Users Say Thank You to butler For This Useful Post:
Posts: 393 | Thanked: 67 times | Joined on Feb 2010
#5
Thanks for the responses, I will analyze this.
 
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#6
Okay, so, how exactly does this work? I take the text, from, say, here: http://www.home.unix-ag.org/simon/woof.html

...then, paste into a file which I then save as "woof"? Or does it have to be "woof.py"? Chmod to make it executable, presumably? I already figured out how to add whatever directory I stick it in to path, just wondering if having .py matters in Linux, since by default file extensions in the file name don't actually matter to linux (As I understand it anyway.)
 
hawaii's Avatar
Posts: 1,030 | Thanked: 792 times | Joined on Jun 2009
#7
Doesn't NEED .py as the top line of the script indicates the "interpreter" to use and the shell will pass it accordingly, upon execution.
 

The Following User Says Thank You to hawaii For This Useful Post:
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#8
(Bah, typed this up like a minute after you - hawaii - posted then walked away from the screen)

Thank you. (Though I managed to dig up the appropriate threads by now. I find lately I am right in between the people who do their own research first and ask later, and the people who ask whatever comes to mind and don't bother searching. (Namely, lately I've been doing some searching, then asking, and proceeding to search in the meantime.)

Either way though, I appreciate your helpful reply. Since it's helpful regardless of whether or not I found the same info in the meantime or not.

(For those like me who are willing-to-learn newbs:
http://talk.maemo.org/showthread.php...d+scripts+path
http://talk.maemo.org/showthread.php...d+scripts+path
These two threads are rather useful for figuring out the script adding thing in my opinion.)

- Edit -

I do seem to be hitting an issue with vi: when making a file for woof, I copy the text from the page I linked to in my above post, and paste in in x-term when in edit mode. I end up encountering an error where vi won't let me add any more characters. Is this supposed to happen? Is it happening on anyone else's N900?

- Edit 2 -

For the time being I copied the file to one of the FAT partitions, renamed it woof.txt, opened in the stock Notes program that came with the phone, pasted script in that way, then saved, renamed it to just woof (for aesthetic appeal for myself), and moved it where I wanted it from x-term. Vi can edit it when it's that big, just not make a file that big to begin with, apparently. *Shrug*

Last edited by Mentalist Traceur; 2010-10-20 at 02:38. Reason: Another question arose. | 2nd Edit: my own unideal solution mentioned).
 
hawaii's Avatar
Posts: 1,030 | Thanked: 792 times | Joined on Jun 2009
#9
Using vi on such a small keyboard is a pain, too many strokes for me.

Use nano.
 

The Following 2 Users Say Thank You to hawaii For This Useful Post:
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#10
Eh, to each their own, and that doesn't explain what happens that makes vi screw up like that.

For me, vi does what I need done, and I am rather minimalistic in my utilities (though based on my conceptions of what I may conceivably some day need and not have internet access to install, this leads to what some might view as the opposite of that).

Anyway, I'm having a wonderful mass of error outputs after copying the script directly from that page, so type to go through the code manually.

line 1: #!/usr/bin/env: not found
(Okay - the original code uses /usr/bin/env python - A few posts up butler uses /usr/bin/python - will try that.)
line 29-33 (same error): import: not found
(Sigh... this means I have to dig up the stuff it's trying to import, doesn't it? Or is it going to be found when/if the code is able to find the right interpreter?)
Line 35: maxdownloads: not found
Line 36: TM: not found
Line 37: cpid: not found
Line 38: compressed: not found
Line 42: syntax error: "(" unexpected
(I'm just gonna suppose that all of these are byproducts of it not finding the python interpreter courtesy of me not checking to make sure it pointed to the right thing.)

Actually, I'll save you the trouble of rereading when I edit this, sine I just tested it with just the first line fixed, and at least "woof -h" works. I leave the above post fragments up for posterity, in case another python+linux newb on here is able to see this if they're having a similar bug, and see how it got solved.

Now, I didn't want to fiddle with .profile making and/or $PATH, so I just put the woof into my /usr/bin directory.
 
Reply


 
Forum Jump


All times are GMT. The time now is 22:21.