How to forward SMB using Ngrok? - smb

I learned about SMB infomation from https://en.wikipedia.org/wiki/Server_Message_Block.
SMB use tcp 139/445 prot. And I check my server prot by lsof,SMB only listen 139 and 445 prot.
Then I try forward SMB port by Ngrok. This is my config:
tunnels:
http:
remote_port: 1122
proto:
tcp: 5000
smb:
remote_port: 139
proto:
tcp: 139
smb2:
remote_port: 445
proto:
tcp: 445
The http server is work. But SMB server not work.
Ngrok clone from https://github.com/inconshreveable/ngrok. Version is 1.7 and build by golang 1.12

Try with this syntax:
smb:
addr: 139
proto: tcp
smb2:
addr: 445
proto: tcp
You can read about ngrok syntax for tunnels in ngrok documentation tunnel definition.

Related

EC2 instance can’t access the internet

Apparently, my EC2 instance can’t access the internet properly. Here is what happens when I try to install a Python module:
[ec2-user#ip-172-31-90-31 ~]$ pip3 install flask
Defaulting to user installation because normal site-packages is not writeable
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fab198cbe10>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /simple/flask/
etc.
However, the website that is hosted on the same EC2 instance can be accessed using both http and https.
The security group is configured as follows:
Port range
Protocol
Source
80
TCP
0.0.0.0/0
22
TCP
0.0.0.0/0
80
TCP
::/0
22
TCP
::/0
443
TCP
0.0.0.0/0
443
TCP
::/0
The ACL inbound rules are:
Type
Protocol
Port range
Source
Allow/Deny
HTTP (80)
TCP (6)
80
0.0.0.0/0
Allow
SSH (22)
TCP (6)
22
0.0.0.0/0
Allow
HTTPS (443)
TCP (6)
443
0.0.0.0/0
Allow
All ICMP - IPv4
ICMP (1)
All
0.0.0.0/0
Allow
All trafic
All
All
0.0.0.0/0
Deny
and the outbound rules are:
Type
Protocol
Port range
Source
Allow/Deny
Custom TCP
TCP (6)
1024 - 65535
0.0.0.0/0
Allow
HTTP (80)
TCP (6)
80
0.0.0.0/0
Allow
SSH (22)
TCP (6)
22
0.0.0.0/0
Allow
HTTPS (443)
TCP (6)
443
0.0.0.0/0
Allow
All ICMP - IPv4
ICMP (1)
All
0.0.0.0/0
Allow
All trafic
All
All
0.0.0.0/0
Deny
This is what the route table associated with the subnet looks like:
Destination
Target
Status
Propagated
172.31.0.0/16
local
Active
No
0.0.0.0/0
igw-09b554e4da387238c
Active
No
(no explicit or edge associations).
As for the firewall, executing sudo iptables –L results in
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
and sudo iptables -L -t nat gives
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
What am I missing here? Any suggestions or ideas on this would be greatly appreciated.
Thanks
You did not list your settings for the Outbound rules of the security group(s) attached to the instance. You should keep the "Allow All" outbound rules to allow the instance to access the Internet.
In general, you should not modify the ACL rules away from their default "Allow All" setting unless you have a very specific need (eg creating a DMZ). I recommend that you start by removing all custom rules from the ACLs and set the 'All traffic' option to "Allow". At least try this temporarily to try and identify the problem.
For example, when establishing a connection to the Internet, traffic will come from a randomly-assigned port. Your ACL is currently blocking all such ports. (To clarify: You might be connecting to port 80 on a remote computer, but that request is not coming from port 80 on your own computer. It is coming from a randomly-assigned port.)

What localhost exactly domains name resolution to ip?

My timing database influx sets the listening port 8088 to address 127.0.0.1, and the spring boot listens to the same port 8088 to any addresses, as shown below.
~ lsof -nP -i:8088
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
influxd 420 zyx 3u IPv4 0xf4af94bc970b15e9 0t0 TCP 127.0.0.1:8088 (LISTEN)
java 34029 zyx 171u IPv6 0xf4af94bc9a0d12e9 0t0 TCP *:8088 (LISTEN)
When I try to access spring boot restful using url localhost:8088/api, I get the right result. But when I use url 127.0.0.1:8088/api, I get error java.net.SocketException: Connection reset.I guess it is caused by mapping to influd instead of spring boot.
But why localhost can get the right result? As far as I konw, localhost will resolve to 127.0.0.1.
I run my program on Mac 2019.
~ nslookup localhost
Server: 192.168.15.1
Address: 192.168.15.1#53
Name: localhost.cluster.peidan.me
Address: 127.0.0.1

pf NAT for local originated traffic

I am trying to proxy 22 traffic, originated from my machine, so it will be proxied / forwarded to a remote server. This was very easy with ipfw but Yosemite has only pf ....
Did anyone found out how to rdr on local (originated from the machine) traffic on OSX Yosemite ?
this is not working !
# Custom pf Rules
#######################################
# target_ip is the ip of which I would like traffic to be proxied
target_ip = "10.0.0.2”
# porxy_ip is the proxy address
porxy_ip = "192.168.1.100”
rdr pass log on lo0 proto tcp from en0 to $target_ip port 80 -> $porxy_ip port 8080
pass out on en0 route-to lo0 inet proto tcp from en0 to $target_ip port 80 keep state
# End
any advise ?

OS X Webserver server does not work

Here is the story. Somehow the spotlinght does not work, called apple support. The conclusion after 2 hour conversation is to clean reinstall the system. I did that and restored everything using time machine.
BUT, the webserver does not work. If can still turn on the web server. But a browser can not load the page. Scanning the port of the server, seems ports 80 and 443 are not even detected. Any one knows how to solve it?
Port Scan has started…
Port Scanning host:
Open TCP Port: 22 ssh
Open TCP Port: 88 kerberos
Open TCP Port: 311 asip-webadmin
Open TCP Port: 445 microsoft-ds
Open TCP Port: 464 kpasswd
Open TCP Port: 548 afpovertcp
Open TCP Port: 625 dec_dlm
Open TCP Port: 631 ipp
Open TCP Port: 749 kerberos-adm
Open TCP Port: 3306 mysql
Port Scan has completed…

Unable to telnet on ec2 even when HTTPS /port 443 is open

Settings of my security group on EC2
TCP
Port(Service) Source Action
22 (SSH) 0.0.0.0/0 Delete
80 (HTTP) 0.0.0.0/0 Delete
443 (HTTPS) 0.0.0.0/0 Delete
Output: When I run the telnet
JP$ telnet passionate4.net
Trying 50.18.159.124...
telnet: connect to address 50.18.159.124: Operation timed out
telnet: Unable to connect to remote host
on ubuntu ec2 server
ubuntu#ip-10-166-185-18:~$ sudo netstat -nup -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:68 0.0.0.0:* 400/dhclient3
Telnet uses port 23, you don't have it in your security group.
type this:
JP$ telnet passionat4.net 80
80, 443, 3389, or whatever port you're testing for.
Windows example:
C:/> telnet www.google.com 80

Resources