diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..81176e4 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +use at ur own risk lmao \ No newline at end of file diff --git a/const.ml b/const.ml new file mode 100644 index 0000000..e69de29 diff --git a/coq_ssh.ml b/coq_ssh.ml index 03a02b9..249d7ec 100644 --- a/coq_ssh.ml +++ b/coq_ssh.ml @@ -1,6 +1,11 @@ +(* ssh rfc: https://datatracker.ietf.org/doc/html/rfc4253 *) + open Unix open Printf + open CoqSSH +open Message +module M = Message let () = let addr_str = "10.7.0.4" in @@ -29,6 +34,28 @@ let () = (* key exchange *) + let kex_msg = M.empty () in + M.add_byte kex_msg msg_kexinit; + (* + byte SSH_MSG_KEXINIT + byte[16] cookie (random bytes) + name-list kex_algorithms + name-list server_host_key_algorithms + name-list encryption_algorithms_client_to_server + name-list encryption_algorithms_server_to_client + name-list mac_algorithms_client_to_server + name-list mac_algorithms_server_to_client + name-list compression_algorithms_client_to_server + name-list compression_algorithms_server_to_client + name-list languages_client_to_server + name-list languages_server_to_client + boolean first_kex_packet_follows + uint32 0 (reserved for future extension) + *) + printf "len %d\n" (M.off kex_msg); + + (* random crap *) + let n : SSH.nat = SSH.O in match n with | SSH.O -> print_endline "o" diff --git a/message.ml b/message.ml new file mode 100644 index 0000000..7c47566 --- /dev/null +++ b/message.ml @@ -0,0 +1,18 @@ +open Char + +(* constants *) +let msg_kexinit = chr 20 + +(* Mutable data structure representing a message *) +module Message = struct + type t = Bytes.t * int ref + + let empty () : t = (Bytes.create 40, ref 0) + + let off (m : t) : int = let (_, len) = m in !len + + let add_byte (m : t) (c : char) : unit = + let (bytes, len) = m in + Bytes.set bytes !len c; + len := !len + 1; +end \ No newline at end of file