Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
ce3f460
fixed string encode/decode errors and updated the package version as …
shasan101 Feb 11, 2025
11b3497
so far only types for generics introduced
shasan101 Feb 11, 2025
753a0a9
introduced types for generics and called the initialize() func in the…
shasan101 Feb 11, 2025
cc288f6
added types to classes dealing with reading the input alphabet(s) fro…
shasan101 Feb 11, 2025
49dcc9e
introduced types to generics and added contructor code before the int…
shasan101 Feb 12, 2025
6571e18
added types for generics and implemented the required override funcs
shasan101 Feb 12, 2025
2efe652
reformatting from the ide
shasan101 Feb 12, 2025
a1989ba
committing the placeholder classes created in trying to get rid of th…
shasan101 Feb 12, 2025
7e418ac
dockerfile for the ssh-mapper
shasan101 Feb 21, 2025
ca82340
added the missing and required SshOutputBuilder class to deal with th…
shasan101 Feb 21, 2025
f323c99
added all the docker related files and also the temp ssh-keys that ca…
shasan101 Feb 21, 2025
2178018
added change to the mapper
shasan101 Feb 21, 2025
e9096b8
added jcommander param to decide whether to run mealy learner or ra l…
shasan101 Feb 21, 2025
c151b4c
fmt pom.xml. minor change in sshMapper
shasan101 Feb 21, 2025
de8395c
revereted the change in mapper.py
shasan101 Feb 21, 2025
1689b55
remved ssh keys. will introduce a script to automate their creation a…
shasan101 Feb 21, 2025
40414a0
added script to generate ssh key at runtime so that the keys are not …
shasan101 Feb 21, 2025
84689c7
basic classes needed to create the RA machine type
shasan101 Feb 25, 2025
a09e9b4
Merge branch 'assist-project:main' into main
shasan101 Feb 26, 2025
48c3207
first attempt at trying to introduce gh workflow.
shasan101 Feb 27, 2025
8ca47da
limiting the learner rounds. added diff checker script - took it form…
shasan101 Feb 27, 2025
673de73
fixed workflow yaml file
shasan101 Feb 27, 2025
9906a63
more syntax errors
shasan101 Feb 27, 2025
b124460
made scripts executable
shasan101 Feb 27, 2025
f66ba58
fixed docker-compose file name. fixed the ssh-keys dir
shasan101 Feb 27, 2025
d76e88a
compose error with container name
shasan101 Feb 27, 2025
bea2d13
run containers as daemon to see if we can run the last stage
shasan101 Feb 27, 2025
180d2f5
creating the output dir for experiments in the script
shasan101 Feb 27, 2025
08f5bd7
the diff script needs the abs path maybe
shasan101 Feb 27, 2025
cda9d48
experimenting with the script
shasan101 Feb 27, 2025
6023c8f
removed the worng check
shasan101 Feb 27, 2025
27ad592
checking dirs at the final stage
shasan101 Feb 27, 2025
7a337fe
need to look at the contents of the learner output dir
shasan101 Feb 27, 2025
6a2cc4f
checking docker cmd
shasan101 Feb 27, 2025
0151694
wait for the learning container to finish
shasan101 Feb 27, 2025
0dc9836
- removed the ssh keys from inside the container. Only mounting from …
shasan101 Mar 5, 2025
d48c52d
moved all the docker related files to a separate dir. updated the scr…
shasan101 Mar 6, 2025
bed7ab2
test the changes with just dropbear
shasan101 Mar 6, 2025
2353fbf
removed unused stage
shasan101 Mar 6, 2025
8ee8eef
fix typo
shasan101 Mar 6, 2025
dc7f9ea
fix typo
shasan101 Mar 6, 2025
8b8d495
found that this os should have the docker-compose preinstalled
shasan101 Mar 6, 2025
fd9b2ca
changed the checkout runner
shasan101 Mar 6, 2025
ec7692d
testing ci
shasan101 Mar 6, 2025
cb29088
testing
shasan101 Mar 6, 2025
86b3244
using docker compose
shasan101 Mar 6, 2025
8d9ca12
- added ci step for openssh server learning.
shasan101 Mar 6, 2025
898a283
running the containers as daemon so that we can conclude the tests on…
shasan101 Mar 7, 2025
71c7869
fixed mapped dir name for openssh
shasan101 Mar 7, 2025
6a3578d
added separate dockerfile and docker-compose for openssh 7. updated t…
shasan101 Mar 13, 2025
3d245a8
fixed e2e tests for openssh8
shasan101 Mar 13, 2025
d311438
running dropbear experiment for only 3 rounds and not 6
shasan101 Mar 13, 2025
4977335
reverted the commented section for key verification
shasan101 Mar 13, 2025
681a054
just running another build
shasan101 Mar 13, 2025
9f73800
openssh8 only producing 2 hypothesis with roundlimit of 3
shasan101 Mar 13, 2025
b146664
Merge branch 'tech/introduce-gh-ci-workflow' into tech/start-on-ra-le…
shasan101 Mar 16, 2025
cb24867
first commit for ra learning. need to fix the ra multibuilder
shasan101 Apr 4, 2025
cd3e30e
wip: last was some error around sul builder
shasan101 Apr 8, 2025
a6f6719
wip: a buildable ra learner for ssh.
shasan101 Apr 16, 2025
6fc1a15
wip: fixing some local issues, but ideally this should be enough
shasan101 Apr 25, 2025
6f08efe
added all the ra learning code which works comlpetely fine
shasan101 May 16, 2025
de34bd4
added input files for ra learning
shasan101 May 16, 2025
99012f6
docker compose files for ra learning as well
shasan101 May 16, 2025
e90643d
updated the start experiment script to work for ra learning as well, …
shasan101 May 16, 2025
2f85b08
learner dockerfile updated to run mealy and ra learner
shasan101 May 16, 2025
af333fe
mapper ajdusted to work with ra learning input and mealy input
shasan101 May 16, 2025
e9ab2e5
learner dockerfile bug fix
shasan101 May 16, 2025
3c1d8fa
added the main class name int he compose file to run either the mealy…
shasan101 May 16, 2025
2347210
added the missing experiment results needed for the ci tests
shasan101 May 16, 2025
09c719c
added back the missing rounds limit to dropbear compose
shasan101 May 16, 2025
246f25e
updated the dockerfile to work with both main classes followed by fix…
shasan101 May 17, 2025
792c27a
added orchestration section to readme explaining how to run the learn…
shasan101 Jun 5, 2025
7162c47
updated script with the latest feedback. updated associated files
shasan101 Jun 10, 2025
28977aa
updated the channel fuzzing to not crash the mapper
shasan101 Jun 10, 2025
e2a741f
Merge branch 'assist-project:main' into tech/start-on-ra-learning
shasan101 Jun 10, 2025
8d61f08
dropbear added missing hyp2
shasan101 Jun 10, 2025
996a604
dropbear added missing hyp3
shasan101 Jun 10, 2025
41e6fd0
added new results for the openssh7 experiment as a new input was added
shasan101 Jun 10, 2025
c7e069b
just removed some old comment
shasan101 Jun 10, 2025
15a6e57
removed needless files and folders
shasan101 Jun 10, 2025
223c3f9
committing empty dirs
shasan101 Jun 10, 2025
f965b83
experimenting
shasan101 Jun 10, 2025
8bb0aa7
experimenting
shasan101 Jun 10, 2025
b30cb4f
check learner logs
shasan101 Jun 11, 2025
eab7741
check mapper logs
shasan101 Jun 11, 2025
b127955
check ssh server logs
shasan101 Jun 11, 2025
e6e03d9
check ssh server logs
shasan101 Jun 11, 2025
b3f1fca
trying compose action
shasan101 Jun 11, 2025
de60347
try new workflow
shasan101 Jun 11, 2025
d025c5d
try new workflow
shasan101 Jun 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions .github/workflows/e2e_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# name: CI for ssh-mapper
# on: [push, pull_request]

# jobs:
# ssh-mapper-dropbear-server:
# if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
# runs-on: ubuntu-latest
# # strategy:
# # fail-fast: true
# steps:
# - name: Checkout code
# uses: actions/checkout@v4

# - name: Start learning DropbearSSH server
# uses: hoverkraft-tech/[email protected]
# with:
# cwd: experiments/orchestration
# compose-file: "docker-compose-dropbear.yaml"
# up-flags: "--build -d"

# - name: Verify Result
# run: |
# # wait for the learning to be over
# while [ "$( docker container inspect -f '{{.State.Running}}' dropbear-learner )" = "true" ]; do date; echo "still learning"; sleep 5; done
# docker logs dropbear-ssh
# docker logs dropbear-mapper
# echo "pwd: "
# pwd
# echo "ls: "
# ls experiments/orchestration/learner_output_dropbear
# experiments/scripts/diff_hyps.sh experiments/results/servers/dropbear experiments/orchestration/learner_output_dropbear 3

# ssh-mapper-openssh7-server:
# if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
# runs-on: ubuntu-latest
# # strategy:
# # fail-fast: true
# steps:
# - name: Checkout code
# uses: actions/checkout@v4

# - name: Start learning OpenSSH7 server
# run: pushd experiments/scripts/ && ./start_learning.sh openssh7 && popd

# - name: Verify Result
# run: |
# # wait for the learning to be over
# while [ "$( docker container inspect -f '{{.State.Running}}' openssh-learner7 )" = "true" ]; do date; echo "still learning"; sleep 5; done
# experiments/scripts/diff_hyps.sh experiments/results/servers/openssh7 experiments/orchestration/learner_output_openssh7 3

# ssh-mapper-openssh8-server:
# if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
# runs-on: ubuntu-latest
# # strategy:
# # fail-fast: true
# steps:
# - name: Checkout code
# uses: actions/checkout@v4

# - name: Start learning OpenSSH8 server
# run: pushd experiments/scripts/ && ./start_learning.sh openssh8 && popd

# - name: Verify Result
# run: |
# # wait for the learning to be over
# while [ "$( docker container inspect -f '{{.State.Running}}' openssh-learner8 )" = "true" ]; do date; echo "still learning"; sleep 5; done
# experiments/scripts/diff_hyps.sh experiments/results/servers/openssh8 experiments/orchestration/learner_output_openssh8 2

name: CI for SSH Mapper (Mealy Learning)
on: [push, pull_request]

jobs:
# This job performs Mealy learning for the Dropbear SSH server
ssh-mapper-dropbear-mealy:
# Skip this job if the commit message contains 'ci skip'
if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}

# Use the latest Ubuntu runner provided by GitHub
runs-on: ubuntu-latest

steps:
- name: Checkout code
# Uses the official GitHub Action to check out your repository code
uses: actions/checkout@v4

- name: Start learning Dropbear SSH server (Mealy Mode)
# Navigate to the scripts directory, execute start_learning.sh for Dropbear, then return.
# The start_learning.sh script handles its own pathing to the orchestration directory.
run: |
echo "Changing directory to experiments/scripts/ and starting learning..."
pushd experiments/scripts/
./start_learning.sh dropbear # 'dropbear' as the single argument triggers Mealy learning
popd
echo "Learning process initiated."

- name: Verify Learning Result
# This step waits for the learner to complete and then verifies its output.
run: |
echo "--- Verifying Learning Results ---"

# IMPORTANT: We need to get the exact container ID for robust inspection.
# We assume the Docker Compose service for the learner is named 'learner' in your docker-compose-dropbear.yaml.
# The docker compose command must be run from the directory where docker-compose.yaml resides.
echo "Retrieving Learner Container ID..."
pushd experiments/orchestration/ # Temporarily change to the orchestration directory
# 'ps -q learner' gets the ID of the 'learner' service in the background
LEARNER_CONTAINER_ID=$(docker compose ps -q learner)
popd # Return to the repository root

if [ -z "${LEARNER_CONTAINER_ID}" ]; then
echo "Error: Learner container ID could not be found." >&2
echo "Please ensure your 'docker-compose-dropbear.yaml' has a service named 'learner' and it starts successfully." >&2
exit 1
fi
echo "Learner Container ID: ${LEARNER_CONTAINER_ID}"

# Wait for the learning process to be over (i.e., the container stops running)
echo "Waiting for learner container to stop..."
# The '2>/dev/null || echo "false"' part handles cases where the container might have already stopped
# or if 'docker inspect' fails for some other reason, preventing the script from breaking.
while [ "$(docker container inspect -f '{{.State.Running}}' "${LEARNER_CONTAINER_ID}" 2>/dev/null || echo "false")" = "true" ]; do
date # Print current date/time for progress tracking
echo "Still learning... (waiting for container ${LEARNER_CONTAINER_ID} to stop)"
sleep 5 # Wait for 5 seconds before checking again
done
echo "Learner container has stopped."

# --- Debugging Information (Essential for troubleshooting if verification fails) ---
echo "--- Debugging Learner Container Logs ---"
echo "Logs for container ${LEARNER_CONTAINER_ID}:"
docker logs "${LEARNER_CONTAINER_ID}" || echo "Could not retrieve logs for ${LEARNER_CONTAINER_ID} (it might have been removed)." >&2

echo "Exit Code for container ${LEARNER_CONTAINER_ID}:"
# Get the exit code; || true prevents this debug line from failing the step itself
docker inspect -f '{{.State.ExitCode}}' "${LEARNER_CONTAINER_ID}" || true
echo "--- End Debugging Learner Container ---"

# List contents of the output directory to verify files were generated
echo "Current working directory before listing output: $(pwd)"
echo "Listing contents of output directory: experiments/orchestration/learner_output_dropbear/"
# '-laR' provides long listing, all files, and recursive listing for subdirectories
ls -laR experiments/orchestration/learner_output_dropbear/ || { echo "Output directory not found or empty." >&2; exit 1; }

# Run the diff script to verify the generated hypothesis against a golden reference
echo "Running hypothesis comparison script..."
# This command's exit code determines the success/failure of this entire step
experiments/scripts/diff_hyps.sh experiments/results/servers/dropbear experiments/orchestration/learner_output_dropbear 3

echo "--- CI Verification Complete Successfully! ---"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ ssh-mapper/paramiko.egg-info/**
ssh-mapper/build/**
ssh-mapper/dist/**
ssh-mapper/mapper/__pycache__/**
ssh-learner/target/**
ssh-learner/target/**
__pycache__/
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,54 @@ The hacked version of paramiko can be found in manualparamiko directory. This fi
Timing variances were a nuisance. Timing is controlled at various places:
- The time.sleep() in mapper/mapper.py (controls set timeout between runs)
- read_multiple_responses() in manualparamiko/transport.py (has both a timeout between responses and total timeout -in case of multiple responses- argument).
- Timeout based on the type of message can be set in the individual read_multiple_responses-calls.
- Timeout based on the type of message can be set in the individual read_multiple_responses-calls.

# Orchestration

Since the components were containerized to make it easy to run and not worry about missing dependencies.

The Mapper and Learner have their Dockerfiles in their own directories. The ssh servers, dropbear and openssh, have their dockerfiles sitting in the `experiments/orchestration/dockerfiles` directory.

In order to start learning most of the setup has been orchestrated with the help of the docker-compose files. All the learners have volume mappings so the learner outputs are available on the host machine. If you need to change or add any extra arguments for any learner or the mapper, you will have to edit the corresponding compose file.

There is a script to simplify the starting of the learning setup where the `ssh-key` pair is also generated which can be used by the mapper. The containers are built locally and then the learning starts.


`cd experiments/scripts`

`./start_learning.sh`

<code>
Usage:
./start_learning.sh <SUT>
./start_learning.sh <SUT> <learning_algorithm>

<SUT> : Required. The SSH server to experiment with.
Must be one of: 'openssh7', 'openssh8', 'dropbear'.
<learning_algorithm> : Optional. Specifies the Register Automata (RA) learning algorithm.
If provided, RA learning mode is activated.
Known algorithms: RALAMBDA RASTAR. Ignored if not applicable.

Examples:
Mealy Learning:
./start_learning.sh openssh8
./start_learning.sh dropbear

RA Learning:
./start_learning.sh dropbear RALAMBDA
./start_learning.sh openssh8 RASTAR
</code>

Whichever learner setup is run, based on the docker-compose file, the results will be generated in the volume mapped in each file, for instance:

<u>Mealy learning dropbear:</u> `experiments/orchestration/learner_output_dropbear`

<u>Mealy learning openssh7:</u> `experiments/orchestration/learner_output_openssh7`

<u>RA learning dropbear:</u> `experiments/orchestration/learner_output_ra_dropbear`

<u>RA learning openssh7:</u> `experiments/orchestration/learner_output_openssh7_ra`


# Trimming script (mypydot)
The python pydot package was altered to merge edges between the same nodes.
Expand Down
51 changes: 0 additions & 51 deletions docker-compose.yaml

This file was deleted.

52 changes: 52 additions & 0 deletions experiments/orchestration/docker-compose-dropbear-ra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: "3.8"

services:
dropbear-ssh-ra:
build:
context: .
dockerfile: dockerfiles/Dockerfile.dropbear
container_name: dropbear-ssh-ra
ports:
- "2222:22"
networks:
- dropbear_network_ra
volumes:
- ./ssh-keys/learner-ssh.pub:/root/.ssh/id_rsa.pub:ro
- ./ssh-keys/learner-ssh:/root/.ssh/id_rsa:ro
entrypoint: ["sh", "-c", "cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && /usr/local/sbin/dropbear -F -E -j -k -s"]


dropbear-mapper-ra:
build:
context: ../../ssh-mapper
dockerfile: Dockerfile
container_name: dropbear-mapper-ra
ports:
- "8080:8080"
depends_on:
- dropbear-ssh-ra
networks:
- dropbear_network_ra
volumes:
- ./ssh-keys/learner-ssh.pub:/root/.ssh/id_rsa.pub:ro
- ./ssh-keys/learner-ssh:/root/.ssh/id_rsa:ro
command: -l 0.0.0.0:8080 -s dropbear-ssh-ra:22 -f server

dropbear-learner-ra:
build:
context: ../../ssh-learner
dockerfile: Dockerfile
container_name: dropbear-learner-ra
networks:
- dropbear_network_ra
depends_on:
- dropbear-ssh-ra
- dropbear-mapper-ra
volumes:
- ./learner_output_ra_dropbear:/app/output_folder
- ../../ssh-learner/inputs/alphabets/servers/:/app/inputs/alphabets/servers/
command: ["java", "-cp", "./ssh-learner.jar:./lib/*", "learner.RALearnerMain", "state-fuzzer-server", "-connect", "dropbear-mapper-ra:8080", "-alphabet", "/app/inputs/alphabets/servers/ra_input.xml", "-output", "/app/output_folder", "-sshMapperAddress", "dropbear-mapper-ra:8080", "-debug", "-learningAlgorithm", "${LEARNING_ALGORITHM}", "-equivalenceAlgorithms", "IO_RANDOM_WALK"]

networks:
dropbear_network_ra:
driver: bridge
52 changes: 52 additions & 0 deletions experiments/orchestration/docker-compose-dropbear.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: "3.8"

services:
dropbear-ssh:
build:
context: .
dockerfile: dockerfiles/Dockerfile.dropbear
container_name: dropbear-ssh
# ports:
# - "2222:22"
networks:
- dropbear_network
volumes:
- ./ssh-keys/learner-ssh.pub:/root/.ssh/id_rsa.pub:ro
- ./ssh-keys/learner-ssh:/root/.ssh/id_rsa:ro
entrypoint: ["sh", "-c", "cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && /usr/local/sbin/dropbear -F -E -j -k -s"]


dropbear-mapper:
build:
context: ../../ssh-mapper
dockerfile: Dockerfile
container_name: dropbear-mapper
# ports:
# - "8080:8080"
depends_on:
- dropbear-ssh
networks:
- dropbear_network
volumes:
- ./ssh-keys/learner-ssh.pub:/root/.ssh/id_rsa.pub:ro
- ./ssh-keys/learner-ssh:/root/.ssh/id_rsa:ro
command: -l 0.0.0.0:8080 -s dropbear-ssh:22 -f server

dropbear-learner:
build:
context: ../../ssh-learner
dockerfile: Dockerfile
container_name: dropbear-learner
networks:
- dropbear_network
depends_on:
- dropbear-ssh
- dropbear-mapper
volumes:
- ./learner_output_dropbear:/app/output_folder
- ../../ssh-learner/inputs/alphabets/servers/:/app/inputs/alphabets/servers/
command: ["java", "-cp", "./ssh-learner.jar:./lib/*", "learner.Main", "state-fuzzer-server", "-connect", "dropbear-mapper:8080", "-alphabet", "/app/inputs/alphabets/servers/trans_auth.xml", "-output", "/app/output_folder", "-sshMapperAddress", "dropbear-mapper:8080", "-debug", "-roundLimit", "3"]

networks:
dropbear_network:
driver: bridge
Loading