aboutsummaryrefslogtreecommitdiff
path: root/src/htbt.c
AgeCommit message (Collapse)Author
2021-08-31MIT LicenseDavid Timber
2021-08-10Impl M2M binary update ...David Timber
* Use getopt in proone-bne * Call pth_yield() where necessary * htbt: truncate downloaded binary if actual size of data transfered is less than alloc_len * prne_rcb_param.self is not optional as proone-bne uses nybin * Add --vercmp option for proone-bne to test M2M bin update * Refactor proone-htbtclient * Protocol change: prne_htbt_bin_meta.alloc_len is now size_t * Add convenience functions: prne_realloc_str(), prne_redup_str()
2021-08-09Protocol and build system change ...David Timber
* Use autoheader * Add --enable-minmem * Add OS code. Bin archive and protocol changed accordingly * Add instance flags in hostinfo frame. Bitfield util added for this * Add org_id in hostinfo for lineage record * SQL schema change: store integer value of hostinfo arch and os * Remove config.c * prne_index_nybin() now sets errno * Instance ids are now preserved for lineage record * Proone: remove arguments after init * Fix bug in prne_htbt_ser_bin_meta(): alloc_len is not checked
2021-08-06htbt and protocol overhaul ...David Timber
* htbt overhaul * Abandon async slv io. slv io is now synchronous * htbt_do_cmd() * w/ detach flag: set up closed pipes for stdio * Create new pg for child and kill the pg on error * Do waitpid() w/ timeout * Wait for child spawn w/ timeout * Always reap child * Add fork cb for clean up code(to unmask signals, deinit libs) * Protocol overhaul * Use stdio frames to transfer binary data for PRNE_HTBT_OP_UP_BIN and PRNE_HTBT_OP_RUN_BIN op * bin_meta bin_size -> alloc_len. This is an optional field now * Fix protocol * detach flag of cmd_head not being (de)serialised * cmd_head (d)ser funcs not setting actual correctly * Proone: call setsid() on daemonisation * Fix compilation error caused by missing <errno.h>
2021-07-25Impl htbt M2M binary update and bug fixes ...David Timber
* Change signature of tmpfile() cb * Add PRNE_DATA_KEY_VER_MAT * Add prne_try_alloc_iobuf() * Fix htbt: don't run cncp when both resolv and cnc_txtrec are not passed * Impl upbin cb on proone-bne * Fix proone-htbtclient: content of status frame was discarded * htbt is now responsible for setting FD_CLOEXEC on temp files * Changes in mttools for valgrind run * Add proone-test_iobuf * Fix event leak in resolv * src/test-resolv.sh: run proone-resolv on valgrind * Add prne_cmp_uuid_asc() and prne_cmp_uuid_desc() for version matrix *
2021-07-22Impl PRNE_HTBT_OP_RCB ...David Timber
* Parameterize prne_start_bin_rcb() args * Change value of PRNE_ARCH_NONE to 0 to use it over the wire (problem arises deserialising) * tostr() and fstr() functions set errno to EINVAL * Run bne without binary archive to support same-arch infection
2021-07-21Impl proone-htbtclient upbin, bug fixes ...David Timber
* Add prne_start_bin_rcb_compat() * PRNE_HTBT_OP_NY_BIN -> PRNE_HTBT_OP_UP_BIN. "nybin" is now the name of the file format * htbt * Fix broken hover redirection (HTBT_LMK_HOVER removed) * HTBT_MAIN_REQ_Q_SIZE * Impl PRNE_HTBT_OP_NOOP response * Fix PRNE_HTBT_OP_SOLICIT is always sent with id 1 * proone * Fix bugs caused by not scrubbing the shared global memory * Fix exec() fail when upbin request with args * Removed do_recombination() as it's not efficient. Now the authoritive end has to do the recombination * PRNE_HTBT_OP_RCB, PRNE_HTBT_STATUS_SUB reserved for future impl
2021-07-19Fix htbt hang, fix proone-hostinfo crash bug ...David Timber
* Fix htbt hang bug - stagnant data in ssl ctx buffer not flushed * Add pending_f() abstraction for mbedtls_ssl_check_pending() * Call read_f() when pending_f() returns true * Add macro functions: prne_is_nberr() and prne_mbedtls_is_nberr() * read_f() and write_f() will always set errno to EAGAIN in the event of MBEDTLS_ERR_SSL_WANT_READ and MBEDTLS_ERR_SSL_WANT_WRITE * proone-hostinfo: fix crash bug when program init is not successful * launch.json: Ignore SIGPIPE to hostinfod
2021-07-14Impl proone-htbtclient, htbt bugfixes ...David Timber
* htbt * Fix stdout-stderr round-robin sending algo in htbt_relay_child() * Fix logic error and crash bug in htbt_slv_srv_bin() * Impl proone-htbtclient runcmd command * Change signature of prne_htbt_set_cmd()
2021-07-12Impl proone-htbtclient, fix htbt ...David Timber
* Fix bug where htbt slv ctx loops when the connection stays on. This bug has not been found earlier because the test connections shutdown write channel * Fix bug where errno is not properly set when htbt_main_do_connect() fails * Add test for protocol enums * proone-htbtclient: impl hover command
2021-07-12Impl proone-htbtclient, bugfix, --enable-mttoolsDavid Timber
* Remove --enable-hostinfod and add --enable-mttools, which enables hostinfod and htbtclient * Change PRNE_HTBT_PROTO_PORT so that the macro can be used in another macro expression(for help message) * Add prne_mbedtls_perror() * proone-htbtclient: implement hostinfo command * proone-htbthost * Add --hostcred option * Response with status frame on ENOMEM * htbt: add prne_htbt_serrc_tostr() and prne_htbt_gen_msgid() * Add prne_ctoupper(), prne_ctolower(), prne_cisspace(), prne_cisprint() * The added functions are the locale-independent equivalent of their POSIX counterparts * Remove Use of the POSIX functions * Add test unit
2021-07-07Refactor: impl prne_mbedtls_verify_alp()David Timber
2021-04-26Tweak and bug fixDavid Timber
* Increase socket operation timeout of htbt and resolv * htbt: use of term "jitter" * htbt: Fix bug where debug print is not suppresses when `PRNE_VERBOSE < PRNE_VL_DBG0` * Fix crash bug caused by SIGPIPE * Proone: `sleep(1)` when fork fails
2021-04-13Debug and impl htbtDavid Timber
* Add debug prints in htbt * Add `prne_htbt_op_tostr()` * Add "Lock Matrix" to throttle hover request from CNC TXT REC and NYBIN race condition * Fix bug where htbt slave does not reset socket operation timeout timer when there's multiple frames in the line * Reserve `PRNE_HTBT_OP_GET_BIN` and `PRNE_HTBT_OP_BIN` for future impl
2021-04-09Impl hostinfod, htbtDavid Timber
* htbt: Call `htbt_cncp_do_probe()` right after start * hostinfod: impl DB thread
2020-11-15Fix improper ssl client config init in prooneDavid Timber
* Fix typo in htbt.c
2020-09-27* Disable armv7, aarch64, x86_64 targetDavid Timber
* Apply recon and bne to proone * Add callback contexts on htbt and bne * Fix mem leak in bne_sh_cleanup_upload() * Use prne_static_assert() instead of _Static_assert() * Use prne_free_worker() rather than calling free_ctx() * Add prne_eq_ipaddr() * bne * Add prne_bne_result::ny_instance to impl infect_cnt * Don't delete tmp upload dir after successful bne_sh_run_exec() so that proone can make tmp files * Silently ignore PRNE_BNE_V_HTBT if htbt_ssl_conf is not set * Add prne_bne_get_subject() * htbt * Fix crash bug when running without resolv * proone: set pth priority
2020-09-24* Impl bneDavid Timber
* Reduce timeout values * Impl telnet vector * Separate stx_str/stx_out and eot_str/eot_out to skip echo * Bugfix: wrong BNE_CONN_OP_TIMEOUT timer reset * vssh: skip account if password auth is not available * bne_vssh_write_f(): propagate write() EOF * No EINTR handling * lssh2_handle() * prne_mbedtls_pth_handle() * resolv_ensure_act_dns_fd() * Add util funcs for telnet login prompt parsing * prne_transmem() * prne_memrmem() * prne_memmem()
2020-09-20* Fix bug in htbt: set client socket non-blockDavid Timber
* htbt: enforce HTBT_LBD_MAX_CLIENTS * Fix bug: wrong use of pth_poll_ev() in * prne_mbedtls_pth_handle() * lssh2_handle()
2020-09-17* Change value types of containers to uintptr_tDavid Timber
* htbt: fix leak in `htbt_main_q_hover()` * proone-recon: fix parse bug
2020-09-15* Code consistency - take *_param_t as pointerDavid Timber
* Fix *_param_t leak and memory error
2020-09-14* Add "--enable-static" configure optionDavid Timber
* Change "PRNE_DEBUG" macro use * Add "PRNE_VERBOSE" * Impl "recon" * Add "inet.h" for Internet Protocol stuff * Changes regarding "PRNE_RND_WELL512_SEEDLEN" * Add prne_own_realloc() for objects with multiple array memebers * Add prne_add_timespec()
2020-09-10* Impl: rnd interface and WELL512David Timber
* cncp: query cnc txt rec after wait not before * In case the child keeps on dying
2020-09-09Add missing shutdown() call @htbtDavid Timber
2020-09-08* Fix bug in pth_poll: wrong use of FD_SET()David Timber
causing undefined behaviour * Fix bug in proone: loading ns pool from dvault for resolv * Fix bug in htbt: improper handling of stream in htbt_relay_child() * Switch back to _POSIX_C_SOURCE=200112L
2020-09-08* Remove proone-unpackDavid Timber
* self test is done by proone-pack * Impl: htbt@proone * htbt: allocate large buffer first by deault * htbt: use 0600 for NY_BIN as the image is not an executable * pack: return error when z_stream is cut short * proone-pack: impl "nybin" file format
2020-09-03* [proone] Use hashed value for shared global fileDavid Timber
name * [htbt] Verify ALPN * [htbt] Bug fixes regarding poll() * [htbt] Run w/o resolv
2020-09-03* Impl: CNCPDavid Timber
* [htbt] Use randomly generated number for SOLICIT request * Die on pth sync funcs only if debug build * Fix wrong use of pth_mutex_acquire(): use with event can result in failure * [htbt] Take "blackhole" fd as param * Remove unused include to reduce compile time * [htbt] Add const macro values for random msg_id gen * [resolv] Make prne_resolv_prm_t reusable * [resolv] Fix mem leak in proone-resolv * [resolv] Sanity check before returning prm so users don't have to worry about SEGFAULT * Add txtrec-*.sh for CNCP
2020-09-02Impl: PRNE_HTBT_OP_HOVERDavid Timber
2020-09-01Impl: htbt_slv abstractionDavid Timber
2020-08-31Impl: NY_BINDavid Timber
2020-08-31Impl run_binDavid Timber
2020-08-30* Impl run_cmdDavid Timber
* Add prne_htbt_hover_t * Add run_cmd test data
2020-08-29* _POSIX_C_SOURCE=199506LDavid Timber
* Add proone-htbthost * Add prne_iobuf, use it in resolv, htbt * memzero() -> prne_memzero() now as a function * Add prne_mbedtls_pth_handle() * Protocol changes * Remove prne_unint_*() * Add src/proone_conf.skel
2020-08-24* htbt checkpointDavid Timber
* Change PRNE_BUILD_ENTROPY to uint8_t array * endian.h problem * Remove "-I." CFLAG added by Automake () * Moved endian conversion macros to endian.h * Moved DNS server config from config.h to resolv.h to reduce compile time * Refactor resolv_ensure_act_dns_fd() to reduce binary size