How can i ngrok edit Forwarding tcp url name and how can i set other name use parameters variables? - linux

ngrok (Ctrl+C to quit)
Tunnel Status online
Version 1.7/1.7
Forwarding tcp://tunnel.123.com:12500 -> 127.0.0.1:22
# Conn 0
Avg Conn Time 0.00ms
How can i change tcp://tunnel.123.com:12500 -> 127.0.0.1:22 to tcp://TEST.123.com:12500 -> 127.0.0.1:22
My config is here
server_addr: "123.com:4443"
trust_host_root_certs: false
tunnels:
ssh:
proto:
tcp: 22
subdomain: TEST
remote_port: 12500

Related

Google cloud engine external access issue

I'm new to Google cloud platform and I didn't understand why I cannot reach a node.js instance running on a new VM.
Node is running on port 8084 through app.listen('8084', "0.0.0.0")
Firewall rules are the following:
gcloud compute firewall-rules list
NAME NETWORK DIRECTION PRIORITY ALLOW DENY DISABLED
default-allow-http default INGRESS 1000 tcp:80 False
default-allow-https default INGRESS 1000 tcp:443 False
default-allow-icmp default INGRESS 65534 icmp False
default-allow-internal default INGRESS 65534 tcp:0-65535,udp:0-65535,icmp False
default-allow-rdp default INGRESS 65534 tcp:3389 False
default-allow-ssh default INGRESS 65534 tcp:22 False
node-8084 default INGRESS 999 tcp:8084 False
netstat:
netstat -na | grep LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8084 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:34339 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:8998 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:65001 0.0.0.0:* LISTEN
tcp6 0 0 :::970 :::* LISTEN
tcp6 0 0 :::980 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::922 :::* LISTEN
I can reach the VM via SSH (port 22) but not through http://35.206.91.238:8084/medical on Chrome. 35.206.91.238 is the external IP showed by google cloud console.
Node.js presents no errors (and no requests).
main code is
var app = express();
app.get('/medical', function(request, response){
if( request.query.q )
run(request.query.q, function(results, queries) { parseResult(q, results, queries, response) } );
})
app.listen('8084', '0.0.0.0')
console.log('Server started on port 8084');
exports = module.exports = app;
Wireshark traffic is only
Only SYN is passing, chrome says "35.206.91.238 refused to connect."
Node is executed manually from shell and doesn't report any error after "Server started on port 8084".
Any idea

portquiz.net dlp test with python

I am trying to get a response from portquiz.net when probing port 80. For example, if we do this:
curl portquiz.net:80
we get the response:
Port 80 test successful!
Here is the python code:
import socket
server = "portquiz.net"
port = 80
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((server, port))
response = s.recv(1024)
print(repr(response))
With this code I get no response, the script just seems to hang.
Is this an issue with my code or is it something to do with portquiz's server?
Fingers, that is an HTTP server, so you need to make a GET request to it. As soon as you connect it is waiting for you to send data, that is why it hangs.
You can do this more easily with an HTTP library, however, if you want to use socket here is the code, with example run:
(xcve) ttucker#plato:~/tmp/stackoverflow/portquiz.net$ cat test.py
import socket
server = "portquiz.net"
port = 80
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((server, port))
# Send HTTP GET request to /
s.send('GET / HTTP/1.1\r\nHOST: {}\r\n\r\n'.format(server).encode())
response = s.recv(1024)
print(repr(response))
(xcve) ttucker#plato:~/tmp/stackoverflow/portquiz.net$ python test.py
b'HTTP/1.1 200 OK\r\nDate: Sun, 21 Jul 2019 22:25:32 GMT\r\nServer: Apache/2.4.29 (Ubuntu)\r\nVary: Accept-Encoding\r\nContent-Length: 2747\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n\n<html>\n<head>\n<title>Outgoing Port Tester</title>\n<style type="text/css">\nbody {\n\tfont-family: sans-serif;\n\tfont-size: 0.9em;\n}\n</style>\n\n</head>\n\n<body>\n<h1>Outgoing port tester</h1>\n\nThis server listens on all TCP ports, allowing you to test any outbound TCP port.\n\n<p>\nYou have reached this page on port <b>80</b>.<br/>\n</p>\n\nYour network allows you to use this port.\n(Assuming that your network is not doing advanced traffic filtering.)\n\n<p>\nNetwork service: http<br/>\nYour outgoing IP: 207.135.66.186</p>\n\n<h2>Test a port using a command</h2>\n\n<pre>\n$ telnet portquiz.net 80 \nTrying ...\nConnected to portquiz.net.\nEscape character is \'^]\'.\n</pre>\n<pre>\n$ nc -v portquiz.net 80 \nConnection to portquiz.net 80 port [tcp/daytime] succeeded!\n</pre>\n<pre>\n$ curl portquiz.net:80 \nPort 80 test successful!\nYour IP: 207.135.66.186</pre>\n<pre>\n$ wget -q'
Further thoughts on this, it looks like the sight might be looking for a CURL header when to determine which version - either HTML, or TEXT - that it sends. It may behoove you to specify the same header after the "HOST: " header that CURL does so the response is easier to parse.
For the example of it with a curl header, and how I figured out what to put there:
(xcve) ttucker#plato:~/tmp/stackoverflow/portquiz.net$ curl portquiz.net:80 -vvvv
* Rebuilt URL to: portquiz.net:80/
* Hostname was NOT found in DNS cache
* Trying 52.47.209.216...
* Connected to portquiz.net (52.47.209.216) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: portquiz.net
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Sun, 21 Jul 2019 22:34:36 GMT
* Server Apache/2.4.29 (Ubuntu) is not blacklisted
< Server: Apache/2.4.29 (Ubuntu)
< Content-Length: 49
< Content-Type: text/html; charset=UTF-8
<
Port 80 test successful!
Your IP: 207.135.66.186
* Connection #0 to host portquiz.net left intact
(xcve) ttucker#plato:~/tmp/stackoverflow/portquiz.net$ cat test.py
import socket
server = "portquiz.net"
port = 80
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((server, port))
get_request = "GET / HTTP/1.1\r\nHOST: {}\r\n" \
"User-Agent: curl/7.35.0\r\n\r\n".format(server)
s.send(get_request.encode())
response = s.recv(1024)
print(repr(response))
(xcve) ttucker#plato:~/tmp/stackoverflow/portquiz.net$ python test.py
b'HTTP/1.1 200 OK\r\nDate: Sun, 21 Jul 2019 22:34:47 GMT\r\nServer: Apache/2.4.29 (Ubuntu)\r\nContent-Length: 49\r\nContent-Type: text/html; charset=UTF-8\r\n\r\nPort 80 test successful!\nYour IP: 207.135.66.186\n'

Node.js server only listening on ipv6

I am running a node.js server on port 5403. I can telent to the private ip on this port but cannot telnet to the public ip on the same port.
I assume the cause of this is because node.js is only listening on ipv6. This is the result of
netstat -tpln
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN
-
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
-
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
-
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
-
tcp6 0 0 :::5611 :::* LISTEN
25715/node
tcp6 0 0 :::22 :::* LISTEN
-
tcp6 0 0 ::1:631 :::* LISTEN
-
tcp6 0 0 :::5403 :::* LISTEN
25709/node
How do I make the node server listen on ipv4
You need to specify an IPV4 address when you call the listen(), I had the same issue with the http module. If I use this:
var http = require('http');
var server = http.createServer(function(request, response) {
...
});
server.listen(13882, function() { });
It only listen on IPV6, as you can see from netstat output:
$ netstat -lntp
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp6 0 0 :::13882 :::* LISTEN
However, if I specify an IPV4 address like this:
var http = require('http');
var server = http.createServer(function(request, response) {
...
});
server.listen(13882, "0.0.0.0", function() { });
netstat will report the server as listening on IPV4:
$ netstat -lntp
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0 0.0.0.0:13882 0 0.0.0.0:13882 LISTEN
I'm using Ubuntu 16.04 and npm 5.3.0.
HTH

tshark SIP protocol display collapse

I'm using tshark protocol filter as I need to parse the contents of the SIP Packets.
tshark -r df32c2248fe646a6793ce9a63b124b34#0.0.0.0.pcap -O sip
I get this:
Frame 14: 553 bytes on wire (4424 bits), 553 bytes captured (4424 bits)
Linux cooked capture
Internet Protocol Version 4, Src: 4.4.4.4 (4.4.4.4), Dst: 3.3.3.3 (3.3.3.3)
User Datagram Protocol, Src Port: 5060 (5060), Dst Port: 5060 (5060)
Session Initiation Protocol (200)
Status-Line: SIP/2.0 200 OK
Status-Code: 200
[Resent Packet: False]
[Request Frame: 11]
[Response Time (ms): 115]
[Release Time (ms): 115]
Message Header
Via: SIP/2.0/UDP 2.2.2.2:5060;received=3.3.3.3;branch=z9hG4bK18f6609d-1c76-4a8b-a96b-2cf7d8036d36_6772d868_3067109296759172
Transport: UDP
Sent-by Address: 2.2.2.2
Sent-by port: 5060
Received: 3.3.3.3
Branch: z9hG4bK18f6609d-1c76-4a8b-a96b-2cf7d8036d36_6772d868_3067109296759172
Contact: <sip:14082186500#1.1.1.1:17060>
Contact URI: sip:14082186500#1.1.1.1:17060
Contact URI User Part: 14082186500
Contact URI Host Part: 1.1.1.1
Contact URI Host Port: 17060
To: <sip:14082186500#spicyramen.ippbx.com;user=phone>;tag=83174026
SIP to address: sip:14082186500#spicyramen.ippbx.com;user=phone
SIP to address User Part: 14082186500
SIP to address Host Part: spicyramen.ippbx.com
SIP To URI parameter: user=phone
SIP to tag: 83174026
From: <sip:anonymous#sip.ie1.sipprovider.com>;tag=87638703_6772d868_18f6609d-1c76-4a8b-a96b-2cf7d8036d36
SIP from address: sip:anonymous#sip.ie1.sipprovider.com
SIP from address User Part: anonymous
SIP from address Host Part: sip.ie1.sipprovider.com
SIP from tag: 87638703_6772d868_18f6609d-1c76-4a8b-a96b-2cf7d8036d36
Call-ID: df32c2248fe646a6793ce9a63b124b34#0.0.0.0
CSeq: 44365 BYE
Sequence Number: 44365
Method: BYE
User-Agent: 3CXPhoneSystem 14.0.44198.522 (44097)
Content-Length: 0
As you can see output is not collapse. I want to see something like this:
Frame 14: 553 bytes on wire (4424 bits), 553 bytes captured (4424 bits)
Linux cooked capture
Internet Protocol Version 4, Src: 4.4.4.4 (4.4.4.4), Dst: 3.3.3.3 (3.3.3.3)
User Datagram Protocol, Src Port: 5060 (5060), Dst Port: 5060 (5060)
Session Initiation Protocol (200)
Status-Line: SIP/2.0 200 OK
Message Header
Via: SIP/2.0/UDP 2.2.2.2:5060;received=3.3.3.3;branch=z9hG4bK18f6609d-1c76-4a8b-a96b-2cf7d8036d36_6772d868_3067109296759172
Contact: <sip:14082186500#1.1.1.1:17060>
To: <sip:14082186500#spicyramen.ippbx.com;user=phone>;tag=83174026
From: <sip:anonymous#sip.ie1.sipprovider.com>;tag=87638703_6772d868_18f6609d-1c76-4a8b-a96b-2cf7d8036d36
Call-ID: df32c2248fe646a6793ce9a63b124b34#0.0.0.0
CSeq: 44365 BYE
User-Agent: 3CXPhoneSystem 14.0.44198.522 (44097)
Content-Length: 0
WiresharkYou can use Wireshark to do the job.
Apply a display filter:
sip
Go to the the Packet Details pane.
Expand "Session Initiation Protocol"
Expand Request-Line, Message Header and Message Body* (do not Expand Subtrees)
Go to File - Export - Export Packet Dissections... - As "Plain Text" File...
Packet Format section: select "Packet Summery Line" and "Packet Details: As Displayed"
Add a file name and save the file
*Note
I have used sample file: aaa.pcap
Message Body: see packet 223
TShark
You can use -T Fields and add all the fields you need.
For example:
tshark -r aaa.pcap -Y sip -E header=y -E separator="?" -T fields -e frame.number -e sip.Request-Line -e sip.r-uri -e sip.Via -e sip.From -e sip.To -e sip.Call-ID -e sip.Contact -e sip.Expires -e sip.CSeq -e sip.User-Agent -e sip.Content-Length > aaa.csv

Dovecot not working pop3 with postfix

telnet localhost pop3
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
netstat -l
tcp 0 0 *:www : LISTEN
tcp 0 0 localhost.localdoma:ipp : LISTEN
tcp 0 0 *:smtp : LISTEN
tcp 0 0 localhost.localdo:mysql : LISTEN
when i run this service dovecot start i got
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.553" (uid=1000 pid=26250 comm="start) interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
on Dovecot.conf
protocols = imap imaps pop3 pop3s
disable_plaintext_auth = no
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/var/spool/mail/%d/%n
mail_access_groups = mail
first_valid_uid = 106
first_valid_gid = 106
protocol imap {
}
protocol pop3 {
listen=*:110
pop3_uidl_format = %08Xu%08Xv
}
protocol lda {
postmaster_address = samer#aiu.com
mail_plugins = quota
log_path = /var/log/dovecot-deliver.log
info_log_path = /var/log/dovecot-deliver.log
}
auth default {
mechanisms = digest-md5 plain
passdb sql {
args = /etc/dovecot/dovecot-mysql.conf
}
userdb sql {
args = /etc/dovecot/dovecot-mysql.conf
}
user = root
}
If you get this message on the command line:
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.553" (uid=1000 pid=26250 comm="start) interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
It indicates that you're not doing service dovecot restart as root. So make sure you do:
sudo service dovecot restart
The directive protocols = imap imaps pop3 pop3s should be sufficient to activate pop3 with dovecot. You can add
listen = *
to be sure dovecot will listen on all available interfaces. You can verify this by netstat -apn | grep 110. Are there any failures while starting dovecot? Can you post the dovecot related logs?
By default, dovecot logs to syslog, you can explicitly specify the log files:
# Log file to use for error messages, instead of sending them to syslog.
# /dev/stderr can be used to log into stderr.
log_path = /var/log/dovecot.log
# Log file to use for informational and debug messages.
# Default is the same as log_path.
info_log_path = /var/log/dovecot.info.log

Resources