Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Lua scripting in honeytrap #427

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

martijnjanssen
Copy link
Contributor

Documentation is also on the way, but if there are questions now, feel free to ask.
Currently, Lua scripting is enabled in both the generic scripter and in the ssh-service. If it is wanted in any other places, some (but minimal) glue-code is required to enable it. The easiest example is the ssh-simulator.

To enable reloading of the scripts, a pr is opened at honeytrap-web, merging that does require a update of the vendor package in here before it is enabled. If testing for the reload is required, checking out the HoneyBEP/honeytrap-web master branch is enough to enable it in honeytrap.

Expand Lua service

Revert unwanted changes

Add command line option to disable lua scripting

Add scripters, scripter config and services scripter initialization

Integrate basic lua scripting into the http service

Update http server and lua implementation (#3)

* Update http server and lua implementation

* Update wordpress links

* Update http

* Update config sample with scripters

* ÃUpdate scripter register function

* Fix gitignore

* Update SetVariable function

* Update Lua variables

* Update variables and http

* Remove newline and old .lua file

Feature support multiple scripts per service (#5)

* Added support for multiple lua scripts for one service

* Added example for multiple scripts per service

Feature lua functions (#4)

* Update lua string functions

* Update datetime function

* Add name to scripter to avoid unneeded arguments (#6)

Fix unneeded arguments

* Fix formatting

* Fix methods and variable names

Remove lua variable function (#8)

* Update lua string functions

* Update datetime function

* Add name to scripter to avoid unneeded arguments (#6)

Fix unneeded arguments

* Remove lua variable function

* Update functions names

* Fix comment and space

* Delete HTTP map

Update http lua script for uniform requirements (#9)

* Update http lua script for uniform requirements

* Update template and remove unused files

* Update template.lua

Feature lua state per connection (#12)

* Initial setup

* Lua scripts are loaded for each connection

* Added commenting

* Remove unneeded info log's

* Remove unneeded comments

* Fixed not returning errors

* Only give error on loading the script

* Continue after script load error

* Removed unneeded cancelFunctions

Feature lua float function (#7)

* Update lua string functions

* Update integer function lua

* Remove duplicate function

* Update comment on function

* Add service name to SetFloatFunction

* Fixed Floatfunction to new connectionStruct

Delete lua-scripts for submodule (#13)

* Delete lua-scripts for submodule

* Update new commits

* Update for travis build

* Update submodule init for lua-scripts

* Update travis ssh rewrite

* Update travis again

* Update travis again

* Gopher-lua in vendor

* Update travis again

* Update travis again

* Update travis again

* Update travis again

* Update lua-scripts to public repo

* Remove update from package for HoneyBEP

* Update lua

Feature parameter function (#14)

* Update parameter function

* Update file permission

* Update comments

Added gopher-lua without submodule (#15)

Move global methods to lua scripter object (#17)

Feature ssh lua implementation (#18)

* SSH lua implementation in exec and channel

* Update scripts

* Added error handling and default result

* Show error when handling of lua goes wrong

Feature ab testing (#19)

* SSH lua implementation in exec and channel

* Added abtester interface and struct

* Finished inital setup abtesting

* Better error handling and comments

Feature SSH uname AB Testing (#20)

* Update ab testing for uname

* Update random int

* Update lua-scripts

Refactored scripts to split data better (#21)

* Refactored scripts to split data better

* Minor go format change

Added a logging method for the scripts (#22)

* Added a logging method for the scripts

* Correct return value for void function

* Split Ab tester from scripter intreface

Fix Handle Parameter and possibility of empty response (#23)

* Fix result return

* Update parameters

* Fix index

* Update util file get create dir

* fix comments

* Fix unwanted code

* Update fix for basic methods

Add generic scripter (#24)

* Add generic scripter

* Add better comments that comply with gometalinter

* Fix field names in struct

* Add missing commend & fix error returns

Implement scripter method & generic scripter expansion (#26)

* Added rest support for lua scripts

* Added rest response for lua

* Added better rest responses

* Add destination and source ip to channelsend

* Removed honeytrap binary

* Added honeytrap binary to gitignore

* Remove binary

* Remove binary pt. 2

* Move html methods to generic scripter

* Extract setBasicMethods

* Extract lua methods

* Fix import & rename ssh-simulator service

* Add missing comments

Made the channel send, also send the response along (#32)

* Made the channel send, also send the response along

* Fix response naming and sending of event in SSH Simulator

* Fix double response

Feature: reload Lua scripts (#25)

* Update lua refresh scripts

* Update gitignore for download files

* Fix for loading folders as lua scripts

* Fix for fix for dir

* Update comment and reload for http

* Update to reload when files are created or deleted

* Update scripts for generic scripter instead of only lua

* Update checksum for edited or new files

* SetInterval update with duration definition

* Update naming for function

* Update uname json for extra test cases (#27)

* Lua scripts update for branch

* Update uname json for extra test cases

* Fixed the reload of scripts via web call

* Remove the interval setup for lua

* Update abtests.json

* Remove redundent files

* Update file requests for Honeytrap (#28)

* Update file requests for Honeytrap

* Update scripts for endpoint controle

* Delete submodule

* Update submodules

* Fix scripts load in folder

* Update new scripts folder

* Remove hash functions

* Fix scripter relation for update

* Update for different files and license

* Update web commands into seperate functions

* Fix build error

* Update get channel for scripters

* Reset vendor honeytrap-web

* Fix basic methods

Fix submodule for scripts

Feature scripter path in lua (#33)

* Set scripter path for each lua script

* Added folder path in lua scripts

Fix double write over connection (#34)

Fix web initialization (#36)

* Fix web initialization

* Update to not global web

* Fix for canHandle of scripts

* Update scripts to latest

Extract abtester as separate entity (#35)

Travis build restart

Add comment

Add cleanuptask for unused scripterConnections (#39)

* Added interval for cleaning unused scripterConnections

* Renamed constants and removed unneeded code

* Added missing comment

* Submodule fix

* Added debug log on remaining connections

Add config setting for scripter connection cleanup (#40)

Tests for generic service with Lua (#37) (#41)

* Init tests for generic service with Lua (#37)

* Init tests for generic service with Lua

* Added more test cases

* Fix tests with context

* Update packages

* Fix tests and generic services based on tests

* Fix preloadLimit error gopher lua

* Fix a lot of tests for the scripter of lua

* Add comments

* Updated tests with more tests

* Test the scripter interface

* rewrite method functions

* Updated tests and comments

* Fix basepath for tests

* Update scripter test init

* Update test scripts folder

* Fixed dummy with clean connections

* Fix last used method on dummy

* Fix log of error in scripter

Fix non lua extension reading of files (#42)

Fix rewrite big methods (#44)

* Fix non lua extension reading of files

* fix rewrite big methods

Improve loglevels & fix formatting (#45)

Skip cleanup without connections & remove http service changes

Remove irrelevant code

Check whether Lua scripts folder exists

Final changes
@codecov-io
Copy link

codecov-io commented Sep 2, 2018

Codecov Report

Merging #427 into master will increase coverage by 1.37%.
The diff coverage is 64.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #427      +/-   ##
==========================================
+ Coverage   41.62%   42.99%   +1.37%     
==========================================
  Files          78       86       +8     
  Lines        8810     9310     +500     
==========================================
+ Hits         3667     4003     +336     
- Misses       4718     4838     +120     
- Partials      425      469      +44
Impacted Files Coverage Δ
services/services.go 10.34% <0%> (-2.16%) ⬇️
server/honeytrap.go 2.84% <0%> (-0.32%) ⬇️
scripter/scripter.go 61.53% <61.53%> (ø)
scripter/dummy.go 63.41% <63.41%> (ø)
services/generic/methods.go 67.12% <67.12%> (ø)
scripter/methods.go 68.33% <68.33%> (ø)
scripter/web.go 69.64% <69.64%> (ø)
scripter/connection.go 76.47% <76.47%> (ø)
scripter/lua/lua.go 76.71% <76.71%> (ø)
scripter/lua/connection.go 77.64% <77.64%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32d1df9...572c1b7. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants