Skip to content

Commit

Permalink
Add: documentation for built-in nasl HTTP Functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Dec 15, 2022
1 parent 8ca6e91 commit 32ca0d9
Show file tree
Hide file tree
Showing 9 changed files with 278 additions and 0 deletions.
29 changes: 29 additions & 0 deletions doc/manual/nasl/built-in-functions/http-functions/cgibin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# cgibin

## NAME

**cgibin** - Get the cgi-bin path elements.

## SYNOPSIS

*void* **cgibin**();

**cgibin** takes no argument.

## DESCRIPTION
Returns the cgi-bin path elements. In fact the NASL interpreter forks and each process gets one value.

## RETURN VALUE
String containing the path.

## EXAMPLES

**1** Get and display the path:
```cpp
path = cgibin();
display (path);
```
## SEE ALSO
**[cgibin(3)](cgibin.md)**, **[http_delete(3)](http.md)**, **[http_get(3)](http.md)**, **[http_close_socket(3)](http.md)**, **[http_head(3)](http.md)**, **[http_open_socket(3)](http.md)**, **[http_post(3)](http.md)**, **[http_put(3)](http.md)**
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# http_close_socket

## NAME

**http_close_socket** - closes a socket.

## SYNOPSIS

*void* **http_close_socket**(*int*);

**http_close_socket** takes one unnamed argument

## DESCRIPTION
It is identical to close but this may change in the future.

## RETURN VALUE


## EXAMPLES

**1** Open and close a socket. Use the socket to send a get request:
```cpp
soc = http_open_socket (port: 80);

url = "http://localhost/";
file = url + "index.html";
req = http_get(port: 80, item: file);

send(socket: soc, data: req);
r = http_recv_headers2(socket:soc);
display (r);

http_close_socket(soc);
```
## SEE ALSO
**[cgibin(3)](cgibin.md)**, **[http_delete(3)](http.md)**, **[http_get(3)](http.md)**, **[http_close_socket(3)](http.md)**, **[http_head(3)](http.md)**, **[http_open_socket(3)](http.md)**, **[http_post(3)](http.md)**, **[http_put(3)](http.md)**
32 changes: 32 additions & 0 deletions doc/manual/nasl/built-in-functions/http-functions/http_delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# http_delete

## NAME

**http_delete** - formats an HTTP DELETE request for the server on the port.

## SYNOPSIS

*void* **http_delete**(port: *int*, item: *string*, data: *string*);

**http_delete** takes three named arguments.

## DESCRIPTION
Formats an HTTP DELETE request for the server on the port.
It will automatically handle the HTTP version and the basic or cookie based authentication. The arguments are port and item (the URL). `data` argument is not compulsory and probably useless in this function.

## RETURN VALUE
It returns a string (the formatted request). Null on error

## EXAMPLES

**1** Get and display the delete request:
```cpp
url = "http://localhost/";
file = url + "puttest" + rand() + ".html";
req = http_delete(port: 80, item: file);
display (req);
```
## SEE ALSO
**[cgibin(3)](cgibin.md)**, **[http_delete(3)](http.md)**, **[http_get(3)](http.md)**, **[http_close_socket(3)](http.md)**, **[http_head(3)](http.md)**, **[http_open_socket(3)](http.md)**, **[http_post(3)](http.md)**, **[http_put(3)](http.md)**
32 changes: 32 additions & 0 deletions doc/manual/nasl/built-in-functions/http-functions/http_get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# http_get

## NAME

**http_get** - formats an HTTP DELETE request for the server on the port.

## SYNOPSIS

*void* **http_get**(port: *int*, item: *string*, data: *string*);

**http_get** takes three named arguments.

## DESCRIPTION
Formats an HTTP DELETE request for the server on the port.
It will automatically handle the HTTP version and the basic or cookie based authentication. The arguments are port and item (the URL). `data` argument is not compulsory and probably useless in this function.

## RETURN VALUE
It returns a string (the formatted request). Null on error

## EXAMPLES

**1** Get and display the delete request:
```cpp
url = "http://localhost/";
file = url + "index.html";
req = http_get(port: 80, item: file);
display (req);
```
## SEE ALSO
**[cgibin(3)](cgibin.md)**, **[http_delete(3)](http.md)**, **[http_get(3)](http.md)**, **[http_close_socket(3)](http.md)**, **[http_head(3)](http.md)**, **[http_open_socket(3)](http.md)**, **[http_post(3)](http.md)**, **[http_put(3)](http.md)**
30 changes: 30 additions & 0 deletions doc/manual/nasl/built-in-functions/http-functions/http_head.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# http_head

## NAME

**http_head** - formats an HTTP HEAD request for the server on the port.

## SYNOPSIS

*void* **http_head**(port: *int*, item: *string*, data: *string*);

**http_head** takes three named arguments.

## DESCRIPTION
Formats an HTTP HEAD request for the server on the port.
It will automatically handle the HTTP version and the basic or cookie based authentication. The arguments are port and item (the URL). `data` argument is not compulsory and probably useless in this function.

## RETURN VALUE
It returns a string (the formatted request). Null on error

## EXAMPLES

**1** Get and display the head request:
```cpp
req = http_head(port: 80, item: "/~root");
display (req);
```
## SEE ALSO
**[cgibin(3)](cgibin.md)**, **[http_delete(3)](http.md)**, **[http_get(3)](http.md)**, **[http_close_socket(3)](http.md)**, **[http_head(3)](http.md)**, **[http_open_socket(3)](http.md)**, **[http_post(3)](http.md)**, **[http_put(3)](http.md)**
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# http_open_socket

## NAME

**http_open_socket** - opens a socket.

## SYNOPSIS

*void* **http_open_socket**(*int*);

**http_open_socket** takes one unnamed argument

## DESCRIPTION
Opens a socket to the given port. It sets a 64K buffer for IO.

## RETURN VALUE
An integer value, the socket

## EXAMPLES

**1** Open and close a socket. Use the socket to send a get request:
```cpp
soc = http_open_socket (port: 80);

url = "http://localhost/";
file = url + "index.html";
req = http_get(port: 80, item: file);

send(socket: soc, data: req);
r = http_recv_headers2(socket:soc);
display (r);

http_close_socket(soc);
```
## SEE ALSO
**[cgibin(3)](cgibin.md)**, **[http_delete(3)](http.md)**, **[http_get(3)](http.md)**, **[http_close_socket(3)](http.md)**, **[http_head(3)](http.md)**, **[http_open_socket(3)](http.md)**, **[http_post(3)](http.md)**, **[http_put(3)](http.md)**
31 changes: 31 additions & 0 deletions doc/manual/nasl/built-in-functions/http-functions/http_post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# http_post

## NAME

**http_post** - formats an HTTP POST request for the server on the port.

## SYNOPSIS

*void* **http_post**(port: *int*, item: *string*, data: *string*);

**http_post** takes three named arguments.

## DESCRIPTION
Formats an HTTP POST request for the server on the port.
It will automatically handle the HTTP version and the basic or cookie based authentication. The arguments are port and item (the URL) and `data`.

## RETURN VALUE
It returns a string (the formatted request). Null on error

## EXAMPLES

**1** Get and display the formatted post request:
```cpp
data = "some data";
req = http_post(port: 80, item: "http://localhost/index.html", data: data);
display (req);
```
## SEE ALSO
**[cgibin(3)](cgibin.md)**, **[http_delete(3)](http.md)**, **[http_get(3)](http.md)**, **[http_close_socket(3)](http.md)**, **[http_head(3)](http.md)**, **[http_open_socket(3)](http.md)**, **[http_post(3)](http.md)**, **[http_put(3)](http.md)**
31 changes: 31 additions & 0 deletions doc/manual/nasl/built-in-functions/http-functions/http_put.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# http_put

## NAME

**http_put** - formats an HTTP PUT request for the server on the port.

## SYNOPSIS

*void* **http_put**(port: *int*, item: *string*, data: *string*);

**http_put** takes three named arguments.

## DESCRIPTION
Formats an HTTP PUT request for the server on the port.
It will automatically handle the HTTP version and the basic or cookie based authentication. The arguments are port and item (the URL) and `data`.

## RETURN VALUE
It returns a string (the formatted request). Null on error

## EXAMPLES

**1** Get and display the formatted put request:
```cpp
data = "some data";
req = http_put(port: 80, item: "http://localhost/index.html", data: data);
display (req);
```
## SEE ALSO
**[cgibin(3)](cgibin.md)**, **[http_delete(3)](http.md)**, **[http_get(3)](http.md)**, **[http_close_socket(3)](http.md)**, **[http_head(3)](http.md)**, **[http_open_socket(3)](http.md)**, **[http_post(3)](http.md)**, **[http_put(3)](http.md)**
17 changes: 17 additions & 0 deletions doc/manual/nasl/built-in-functions/http-functions/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# HTTP Functions

## GENERAL

These functions are mainly used for formating HTTP request, and for opening and closing http sockets.

## TABLE OF CONTENT

**cgibin** - Get the cgi-bin path elements.
**http_delete** - formats an HTTP DELETE request for the server on the port.
**http_get** - formats an HTTP GET request for the server on the port.
**http_close_socket** - closes an HTTP socket.
**http_head** - formats an HTTP HEAD request for the server on the port.
**http_open_socket** - opens a socket to the given port.
**http_post** - formats an HTTP POST request for the server on the port.
**http_put** - formats an HTTP PUT request for the server on the port.

0 comments on commit 32ca0d9

Please sign in to comment.