|
1 | 1 | # python-filt |
2 | | -The libraries for filt. |
| 2 | +## Overview |
| 3 | +Python filt is the packeage for using [Filt](https://github.com/akakou/filt). |
| 4 | +You can use to make below. |
| 5 | + |
| 6 | +### Filt Client |
| 7 | +Use filt to check whether the target hits the signature. |
| 8 | + |
| 9 | +### Filt Scanner |
| 10 | +Get target and signature, check whether the target hits the signature, and return result to Filt. |
| 11 | + |
| 12 | +## Installation |
| 13 | +Type command below. |
| 14 | + |
| 15 | +```sh |
| 16 | +$ git clone https://github.com/akakou/python-filt |
| 17 | +$ cd python-filt |
| 18 | +$ sudo pip install . |
| 19 | +``` |
| 20 | + |
| 21 | +## How to make scanner |
| 22 | +### 1. project directory |
| 23 | +Make the project folder. |
| 24 | +```sh |
| 25 | +$ mkdir sample |
| 26 | +$ cd sample |
| 27 | +``` |
| 28 | + |
| 29 | +### 2. `Settings.toml` |
| 30 | +Make `Setting.toml` in project directory |
| 31 | +```Settings.toml |
| 32 | +# this is sample/Settings.toml |
| 33 | +excutable_file = "scanner.py" |
| 34 | +``` |
| 35 | + |
| 36 | +### 3. python file |
| 37 | +Make python file and write like below. |
| 38 | +```python |
| 39 | +#!/usr/bin/env python |
| 40 | +""" |
| 41 | +This is sample/scanner.py |
| 42 | +""" |
| 43 | + |
| 44 | +from filt.scanner import BaseScanner |
| 45 | + |
| 46 | +# **DO NOT use** stdin and stdout. |
| 47 | +# Scanner use them to communicate with filt. |
| 48 | + |
| 49 | +class SampleScanner(BaseScanner): |
| 50 | + def scan(self, target, signature): |
| 51 | + """ |
| 52 | + Check target and signature, |
| 53 | + and return is_hit(bool) and message(str). |
| 54 | + """ |
| 55 | + # WRITE HERE |
| 56 | + return (is_hit, message) |
| 57 | + |
| 58 | +if __name__ == '__main__': |
| 59 | + # run scanner |
| 60 | + sample_scanner = SampleScanner() |
| 61 | + sample_scanner.run() |
| 62 | +``` |
| 63 | + |
| 64 | +## How to make client |
| 65 | +Make python file and write like below. |
| 66 | + |
| 67 | +```python |
| 68 | +#!/usr/bin/env python |
| 69 | +from filt.client import FiltClient |
| 70 | + |
| 71 | + |
| 72 | +def main(): |
| 73 | + # set param |
| 74 | + url = 'https://localhost:3000' |
| 75 | + target = "hello world" |
| 76 | + option = {"hoge": "fuga"} |
| 77 | + |
| 78 | + # construct filt client |
| 79 | + filt = FiltClient(url) |
| 80 | + |
| 81 | + # send data to filt |
| 82 | + result = filt.send(target, verify=False) |
| 83 | + print(result) |
| 84 | + |
| 85 | + # add option and send data |
| 86 | + result = filt.send(target, option=option, verify=False) |
| 87 | + print(result) |
| 88 | + |
| 89 | + |
| 90 | +if __name__ == '__main__': |
| 91 | + main() |
| 92 | +``` |
0 commit comments