golang get network port friendly description - go

I am building a port scanner to learn go, so please, don't be rude with me.
I want a way to get the description of a port programmatically in go
Example:
API.GetPortDescription(22) -> ssh
API.GetPortDescription(80) -> http
API.GetPortDescription(433) -> https
i tried parsing /etc/services file, but my poor knowledge of go didn't help
i did something similar in java

Related

Zgrab2 - adding new protocols

I am trying to add DNS over TLS (DoT) protocol to the zgrab2 tool. I used the zgrab2 documentation but I am not able to figure it out. Has anyone added a new protocol that is not there like port 853? ZGrab2 has the common ports but not post 2015.
From my understanding, you need to write your own code for DNS over TLS (DoT) in golang,
and then run an integration test on it. I understand the latter but have no idea how to create a module for port 853.
Would appreciate any suggestions or useful links anyone has. Thanks!

Golang `pions` lib example issue

I've just started experimenting with WebRTC with Go and downloaded pions/webrtc library but I'am stuck with it's data-channels example.
As it written in docs I opened jsfiddle client example.
Then I'am running go run main.go command in the /go/src/github.com/pions/webrtc/examples/data-channels folder on my server to launch data-channel.
After that I copy Browser base64 Session Description from jsfiddle example and paste it into my terminal where data-channels go script is running and it generates Golang base64 Session Description code which I paste into jsfiddle example and then press Sart session button.
And it fails to establish connection :(
This is my jsfiddle example for client side:
And this is my server side go script:
What am I doing wrong?
Thanks for using pion-WebRTC (I am one of the developers!)
WebRTC uses a technology called ICE to allow peers to talk to each other. Two peers exchange IP addresses via the SDP (the text you pasted) then they attempt to communicate by sending small UDP packets between each other. Once two IP addresses successfully communicate via ICE the rest of the WebRTC steps can continue. For you this process is failing. I don't know how/why though. Firewalls, VPNs etc... all can cause problems.
You will have to debug and check different scenarios. I would try running the examples on your local PC. If that works then maybe try between a different server. A good tool to help here also is tcpdump that can show if UDP packets are arriving. I usually use tcpdump -i any udp and inbound
We also recently added IPv6 support, so might be worth trying from master and see if that helps at all! Hopefully this helps, but if you are still having issues feel free to ask more questions. We are also all available via our Slack Channel you can sign up here here and would be more then happy to chat!
I met similar problem, and I solved by
echo $BROWSER_SDP | ./main
BROWSER_SDP is the session description in your browser, main is the exe by go build main.go(you can rename exe by mv). This can make sure transfer SDP to the server, which is really important.
The detail

HTTPS thought shadowsocks --mptcp

I would like to ask if it is possible to forward HTTPS through the following diagram
A USER -> Wi-Fi -> SQUID -> SHADOWSOCKS_CLIENT -> MPTCP -> SHADOWSOCKS_SERVER -> INTERNET
HTTP is working.
We have already ask for here for advice how to use shadowsocks properly for https (https://github.com/shadowsocks/shadowsocks-libev/issues/926)
However there might be other solutions.
I would like to ask for an advice.
thank you

how to set up a vpn connection programmatically in MAC?

after searching for a while i found that the only best source available to establish a vpn connection programmatically in mac is at
http://lists.apple.com/archives/Macnetworkprog/2011/May/msg00032.html
but i was struck at the 5th point while coding which says about kSCNetworkProtocolTypePPP and there is no such thing...
has anybody done it as shown in the above link
or is there any other source available...?
but i was struck at the 5th point while coding which says about kSCNetworkProtocolTypePPP and there is no such thing...
There is no need to fetch the PPP protocol, you can apply the settings directly to the interface you created. If you created the interface like this:
interface = SCNetworkInterfaceCreateWithInterface(bottomInterface, kSCNetworkInterfaceTypePPP);
you can apply the PPP options directly using:
SCNetworkInterfaceSetConfiguration(interface, myOptions)
You'll have to apply the shared secret using
SCNetworkInterfaceSetExtendedConfiguration(interface, CFSTR("IPSec"), myOptions)
And if you want to enable "Send all traffic over VPN", you'll need to apply those settings by fetching the IPv4 protocol first:
SCNetworkProtocolRef protocol = SCNetworkServiceCopyProtocol(service, kSCNetworkProtocolTypeIPv4);
SCNetworkProtocolSetConfiguration(protocol, myOptions)
The source code mentioned in this answer was extracted from https://github.com/halo/macosvpn/blob/master/macosvpn/Classes/VPNController.m where you can find it in its entirety.

How to determine what URL a closed source piece of software is connecting to? (OSX)

Usually I'd use Wireshark, but is there a really super quick way to determine what URL an app is pulling data from? I need to whitelist the host so that it works through a proxy server, as the app doesn't support proxies.
Fire up terminal and type
lsof -i
this lists all open internet connections. Of course you can restrict the listing to include only connections from certain executable with -c option. Read the man page for lsof. Learn to use it, it's a great little tool.
Check out Little Snitch http://www.obdev.at/products/littlesnitch/index.html
Great little program to catch those "phone homes". Cheap too!
Give this a shot:
Charles Web Debugging Proxy
It's not quite as heavy as Wireshark so you should be able to get your results pretty quick. Short of something like Wireshark or a HTTP Debugging Proxy, I'm not sure how you'd know.

Resources