chevron_left chevron_right
Login Register invert_colors photo_library

Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average

Tutorial Lilith API Walkthorough filter_list
Lilith API Walkthorough #1
Yay, more tools! And a hostname to boot!

Anyway, it's 4 AM again, and I just finished the first few patches on my API server, so I thought I'd do a runthrough of how it all works.

If you've looked at the project page (link in my sig), you'll have seen that there are two ways of using Lilith: POST and Query Strings. POST requests will become more important when I add any kind of file management API, so We'll go over the Query String option first.

Query Strings, as a refresher, are the text following a question mark in a url. This text usually represents input values for html forms, but can be parsed to a hash table with PHP, which is what I did.

To get a response from Lilith with a Query, it's just the following few lines with python:
from requests import get

print get('<action>[&args=[args]]).text
Or just one with curl:
curl '<action>[&args=[args]]'

An example of what to use could be 'ip', which doesn't take arguments, or 'gw-ip', which would take a domain name, ie '', as it's parameter.

You can also choose which output format you want from either json (which is the default), plain text, or j-box, from J Language. You can access these by passing the rtype parameter in your Query.
$ curl ''
{"ip": ""}

$ curl ''
ip |

$ curl ''
| ip | |

For the POSTing side of things, using RESTful APIs can get really confusing in some languages, so I'm just going to stick with python.

Basic ip request:
from requests import post

print post(url='',files={'action': 'ip'}).text

More complex DNS resolution with jbox return type:
from requests import post

print post(
    url='', #base url
    files={                     #start of parameters
        'action': 'gw-ip',      #equivilant to ?action=gw-ip
        'args': '',
        'rtype': 'jbox'         #rtype=jbox
).text                          #get the text from the page

Sorry this wasn't super informative, I should be waking up in 2 hours, so I'm kinda tired. Anyway, enjoy, and feel free to check out the project.

EDIT: POST requests are fucked in python, so just stick with Query Strings.


Users browsing this thread: 1 Guest(s)