Skip to content

Commit 84aaf9a

Browse files
...
Image update. Displays JSON Add help
1 parent 6b36b3d commit 84aaf9a

File tree

7 files changed

+79
-20
lines changed

7 files changed

+79
-20
lines changed

.github/workflows/docker-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
uses: docker/build-push-action@v5
5252
with:
5353
platforms: linux/amd64,linux/arm64
54-
context: docker
54+
context: .
5555
push: ${{ github.event_name != 'pull_request' }}
5656
tags: ${{ steps.meta.outputs.tags }}
5757
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
1-
# Node-scan
1+
# Codespaces Node Scan
22

3-
[![node-scan](https://github.com/RootShell-coder/codespaces-node-scan/actions/workflows/docker-image.yml/badge.svg)](https://github.com/RootShell-coder/codespaces-node-scan/actions/workflows/docker-image.yml)
3+
[![codespaces-node-scan](https://github.com/RootShell-coder/codespaces-node-scan/actions/workflows/docker-image.yml/badge.svg)](https://github.com/RootShell-coder/codespaces-node-scan/actions/workflows/docker-image.yml)
44

5-
`docker run -ti --rm ghcr.io/rootshell-coder/codespaces-node-scan:latest <ip or pool> <port or range>`
5+
The `codespaces-node-scan` it's scanner can be used in CI to detect host availability and open ports. Displays data in JSON format.
66

7-
example
7+
`docker run -i --rm ghcr.io/rootshell-coder/codespaces-node-scan:latest <ip or pool(-)> <port or range(-) or ports(,)>`
88

9-
`docker run -ti --rm ghcr.io/rootshell-coder/codespaces-node-scan:latest 8.8.8.8 53`
9+
## example usage
1010

11-
`docker run -ti --rm ghcr.io/rootshell-coder/codespaces-node-scan:latest 192.168.0.1-254 22-443`
11+
help
12+
13+
`docker run -i --rm ghcr.io/rootshell-coder/codespaces-node-scan:latest --help`
14+
15+
output
16+
17+
```
18+
Node-scan CI component usage:
19+
Help: codespaces-node-scan --help or empty
20+
Scan example target ports: codespaces-node-scan 8.8.8.8 53,443
21+
Scan example range hosts and port: codespaces-node-scan 192.168.0.2-254 80
22+
Scan example range hosts and ports: codespaces-node-scan 192.168.0.27-192.168.0.254 22-443
23+
```
24+
25+
scan host and port
26+
27+
`docker run -i --rm ghcr.io/rootshell-coder/codespaces-node-scan:latest 8.8.8.8 53`
28+
29+
output
30+
```json
31+
[
32+
{
33+
"result": "ok"
34+
},
35+
{
36+
"ip": "8.8.8.8",
37+
"port": 53,
38+
"banner": "",
39+
"status": "open"
40+
}
41+
]
42+
```
43+
44+
## build
45+
46+
```bash
47+
git clone https://github.com/RootShell-coder/codespaces-node-scan.git .
48+
docker build -t node-scan -f docker/Dockerfile .
49+
```

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM node:current-alpine
2-
COPY entrypoint /usr/sbin
2+
COPY docker/entrypoint /usr/sbin
33
RUN set -eux; \
44
apk add --update --no-cache \
55
bash \
@@ -10,6 +10,6 @@ RUN set -eux; \
1010
chmod +x /usr/sbin/entrypoint;
1111
USER node-scan:node-scan
1212
WORKDIR /home/node-scan
13-
COPY --chown=node-scan:node-scan index.js package.json ./
13+
COPY --chown=node-scan:node-scan docker/index.js docker/package.json ./
1414
RUN npm update
1515
ENTRYPOINT [ "entrypoint" ]

docker/entrypoint

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
#!/bin/ash
2-
3-
if [[ -n $1 ]]
2+
if [ -z "$1" ] || [ "$1" = "--help" ]
3+
then
4+
echo "Node-scan CI component usage:"
5+
echo "Help: codespaces-node-scan --help or empty"
6+
echo "Scan example target host and ports: codespaces-node-scan 8.8.8.8 53,443"
7+
echo "Scan example range hosts and port: codespaces-node-scan 192.168.0.2-254 80"
8+
echo "Scan example range hosts and ports: codespaces-node-scan 192.168.0.27-192.168.0.254 22-443"
9+
exit
10+
fi
11+
if [ -n "$1" ]
412
then
5-
if [[ -n $2 ]]
13+
if [ -n "$2" ]
614
then
7-
sed -i "s/target ip address/${1}/" /home/node-scan/index.js
8-
sed -i "s/target port/${2}/" /home/node-scan/index.js
9-
npm start
15+
sed -i "s/target ip address/${1}/" /home/node-scan/index.js 2>/dev/null
16+
sed -i "s/target port/${2}/" /home/node-scan/index.js 2>/dev/null
17+
npm start > /dev/null 2>&1
18+
if [ -f ./result.json ]
19+
then
20+
cat ./result.json
21+
else
22+
echo -e "[\n {\n \"result\": \"error\"\n }\n]"
23+
fi
1024
exit
1125
fi
1226
fi
13-
echo "Help: docker run -ti --rm node-scan 192.168.0.1-254 22-433"

docker/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@ const options = {
1313

1414
const evilscan = new Evilscan(options);
1515

16+
17+
const fs = require('fs');
18+
const results = [];
19+
1620
evilscan.on('result', data => {
17-
console.log(data);
21+
results.push(data);
22+
});
23+
24+
evilscan.on('done', () => {
25+
const first = {"result": "ok"};
26+
const data = [first].concat(results);
27+
fs.writeFileSync('result.json', JSON.stringify(data, null, 2) + '\n');
1828
});
1929

30+
2031
evilscan.on('error', err => {
2132
throw new Error(data.toString());
2233
});

version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)