-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*.cr] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github: noraj | ||
issuehunt: noraj | ||
ko_fi: noraj | ||
liberapay: noraj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/lib/ | ||
/bin/miniss | ||
/bin/miniss.o | ||
/bin/miniss.dwarf | ||
/.shards/ | ||
*.dwarf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
crystal 1.7.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# miniss | ||
|
||
**miniss** (_mini ss_) displays a list of open listening sockets. It is a minimal alternative to `ss` or `netstat`. | ||
|
||
The goal of **miniss** is not to reinvent the wheel but rather to offer a static binary that can be deployed by pentester or CTF players on containers or hardened environnement where the classical `ss` or `netstat` binaries have been removed. | ||
|
||
## Installation | ||
|
||
TODO: Write installation instructions here | ||
|
||
## Usage | ||
|
||
``` | ||
./miniss | ||
``` | ||
|
||
## Features | ||
|
||
- Information displayed: | ||
- local address, remote address, state, username, uid | ||
- Type of sockets: | ||
- [x] TCP | ||
- [ ] UDP | ||
- IP version: | ||
- [x] IPv4 | ||
- [ ] IPv6 | ||
|
||
## Author | ||
|
||
- [noraj](https://pwn.by/noraj/) - creator and maintainer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "miniss/cli" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[0.0.1] | ||
|
||
- Early alpha release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
TODO: | ||
|
||
- Code: | ||
- Create a socket class for socket objects | ||
- Refactor code between cli & lib | ||
- IPv6 support | ||
- Doc: | ||
- https://crystal-lang.org/reference/1.7/syntax_and_semantics/documenting_code.html | ||
- https://crystal-lang.org/reference/1.7/man/crystal/#crystal-docs | ||
- https://github.com/GeopJr/vitepressify | ||
- Lint: | ||
- https://github.com/crystal-ameba/ameba | ||
- Test: | ||
- https://github.com/ysbaddaden/minitest.cr | ||
- https://crystal-lang.org/api/1.7.2/Spec.html | ||
- Optparse: | ||
- https://github.com/chenkovsky/docopt.cr | ||
- Color: | ||
- https://crystal-lang.org/api/1.7.2/Colorize.html | ||
- Shard registries: | ||
- https://github.com/shardbox/catalog/blob/master/README.md | ||
- Branding: | ||
- Make a logo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Compile: | ||
|
||
https://github.com/crystal-lang/crystal/issues/9285#issuecomment-1445493032 | ||
|
||
``` | ||
crystal build src/miniss.cr --release --static -o bin/miniss | ||
shards build --release --static | ||
docker run --rm -it -v $PWD:/workspace -w /workspace crystallang/crystal:1.7.2-alpine \ | ||
crystal build src/miniss.cr --release --static -o bin/miniss | ||
docker run --rm -it -v $PWD:/workspace -w /workspace crystallang/crystal:1.7.2-alpine \ | ||
shards build --release --static | ||
$ llvm-config --host-target | ||
$ docker run --rm -it -v $PWD:/workspace -w /workspace crystallang/crystal:1.7.2-alpine \ | ||
crystal build src/miniss.cr --release --static -o bin/miniss --cross-compile --target x86_64-pc-linux-gnu | ||
$ docker run --rm -it -v $PWD:/workspace -w /workspace crystallang/crystal:1.7.2-alpine \ | ||
cc bin/miniss.o -o bin/miniss -rdynamic -static -L/usr/bin/../lib/crystal -lpcre -lm -lgc -lpthread -levent -lrt -lpthread -ldl | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Contributing | ||
|
||
1. Fork it (<https://github.com/your-github-user/miniss/fork>) | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create a new Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## Development | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: miniss | ||
version: 0.0.1 | ||
description: Displays a list of open listening sockets. It is a minimal alternative to ss or netstat. | ||
|
||
authors: | ||
- Alexandre ZANNI <alexandre.zanni@europe.com> | ||
|
||
targets: | ||
miniss: | ||
main: src/cli.cr | ||
|
||
executables: | ||
- miniss | ||
|
||
crystal: "~> 1.7.2" | ||
|
||
license: MIT | ||
documentation: https://github.com/noraj/miniss/tree/master/docs | ||
homepage: https://github.com/noraj/miniss | ||
repository: https://github.com/noraj/miniss | ||
|
||
dependencies: | ||
development_dependencies: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require "./miniss/cli/cmd" | ||
|
||
Miniss::Cli.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require "./miniss/*" | ||
require "./miniss/etc/**" | ||
# TODO: Write documentation for `Miniss` | ||
module Miniss | ||
VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require "../miniss" | ||
|
||
module Miniss | ||
def self.decode_addr(addr) | ||
ip, port = addr.split(":", remove_empty: true) | ||
ip = ip.scan(/.{2}/).reverse_each.join('.'){ |x| x[0].to_i(16) } | ||
port = port.to_i(16).to_s | ||
"#{ip}:#{port}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "../../miniss" | ||
|
||
# :nodoc: | ||
module Miniss::Cli | ||
def self.run | ||
puts "local address".ljust(22) + "remote address".ljust(22) + "state".ljust(12) + "username (uid)" | ||
File.read_lines("/proc/net/tcp").each_with_index do |line, i| | ||
entry = line.split(" ", remove_empty: true) | ||
unless i == 0 # skip headers | ||
laddr = Miniss.decode_addr(entry[1]) | ||
raddr = Miniss.decode_addr(entry[2]) | ||
state = Miniss::TCP_STATES[entry[3]] | ||
uid = entry[7] | ||
uname = Miniss::Etc.getpwuid(uid) | ||
puts "#{laddr.ljust(22)}#{raddr.ljust(22)}#{state.ljust(12)}#{uname} (#{uid})" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "../miniss" | ||
|
||
module Miniss | ||
TCP_STATES = { # /usr/src/linux/include/net/tcp_states.h | ||
"00" => "UNKNOWN", | ||
"FF" => "UNKNOWN", | ||
"01" => "ESTABLISHED", | ||
"02" => "SYN_SENT", | ||
"03" => "SYN_RECV", | ||
"04" => "FIN_WAIT1", | ||
"05" => "FIN_WAIT2", | ||
"06" => "TIME_WAIT", | ||
"07" => "CLOSE", | ||
"08" => "CLOSE_WAIT", | ||
"09" => "LAST_ACK", | ||
"0A" => "LISTEN", | ||
"0B" => "CLOSING", | ||
"0C" => "NEW_SYN_RECV" | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Miniss::Etc | ||
def self.getpwuid(uid) | ||
File.read_lines("/etc/passwd").each_with_index do |line, i| | ||
entry = line.split(":", remove_empty: false) | ||
return entry[0] if entry[2] == uid | ||
end | ||
end | ||
end |