Metasploit handler failed to bind to port 4444 - virtual-machine

I am running Kali Linux on VMware. The host operating system is windows 7, and I'm using NAT for connectivity.
In my metasploit console, when I typed 'exploit' at the msf prompt,(where I am using windows/meterpreter/reverse_tcp as the payload) it showed me the error
Handler failed to bind to My IP:4444
(My IP is my external IP address.)
So in the VMware virtual network editor, I have port forwarded port 4444 of host PC to port 4444 of the virtual PC. Then I allowed inbound packets in the firewall of the host PC, for port 4444 of the host PC.
To ensure that everything is alright, I set up an apache server on the virtual PC, that serves a webpage when accessed via port 4444. The server served flawlessly when I accessed it with an external browser. Satisfied, I shut down the server.
But guess what? Metasploit console has thrown up the same error when I typed 'exploit' again in the msf prompt.
What to do now?

What did it say the reason for failing was.
I'm assuming the full error was failed to bind to port 4444 port is already in use.
You can not run a server on the same port you are trying to bind to.
The correct way to do this is to port forward through your router. Open your router settings and port forward port 4444 to your machines local ip.

Related

How to send SQL queries to a computer outside of the network through port?

I have a java program that uses SQL queries. The goal is to send them from my home PC to a workstation on a different network elsewhere.
The SQL server is on Windows Server and I opened port 1433 for inbound connections. From that computer, I can successfully ping the port. However, I can't ping the port from the public ip address, only the local (192.168...), so it doesn't work if I were to try to ping it from my home computer.
Is there a way that I can ping it from my home computer? If so, how would I specify the address for JDBC?
Thanks!
It sounds like your Windows Server is behind an internet gateway/router. You need to configure the gateway to allow and forward inbound connections to TCP port 1433 to the IP of the computer that has SQL Server installed.
Here are some guides that explain how to enable port forwarding on different devices:
How to Forward Ports on Your Router (lifewire.com)
How to Port Forward (No-IP.com)
Also, note that we can ping IP addresses, not ports.

Can't connect despite port forwarding

I have a Ubuntu Server 16.04 running on a machine in my local network.
The machine has static assigned IP and running apache2. There is no problem in connecting to it from my local network.
I have port-forwarding for ports 22 and 80 setup on my router to the IP address of the machine.
When I check the ports with my public IP address on sites like http://www.canyouseeme.org/ the result is that the ports are open. When I try to connect using my public IP address and using those ports the connections are refused.
I tried disabling firewall in the router and also on the machine, no result.
What else should I try? It seems that the server is getting no incoming connection when I check with netstat.
Just for troubleshooting purposes:
Setup port forwarding on port 22 and try to ssh into your server using the public IP? If it works, it means apache is refusing the connections and not your router or ISP
On your router, setup the server on the DMZ temporarily and check if it works
Add another port forwarding rule on your router to redirect all http requests on port 8000,for example, to port 80 internally, then try to access your server with http://[public_ip]:8000
Have you changed anything on the apache2.conf file? Also, explain how you are testing the connection, internally using the public IP or from the Internet?

Network issue between VMWare guest and windows host

I have a windows 7 host, on which I am also running a windows 7 virtual machine, essentially I'm trying to setup buildbot, the host runs the build master while the vmware virtual machine will run the build worker. The virtual machine network adapter is configured to host only. The virtual machine It has an ip address of 192.168.1.12, while the host has an ip address of 192.168.1.92. Both addresses are static IPs there's no DHCP involved
I can ping the host from the virtual machine, and I can ping the virtual machine from the host.
But when I try to get both the build master(host) and the build worker(vm) to communicate, nothing seems to happen. Looking at the twisted log in the vm I can see error messages along the lines of
"TCP connection failed to connect to host on ip 192.168.1.92:8999"
Note the buildbot.tac on the build worker(vm) has the ip address of the host (192.168.1.92) and the port on which to connect 8999
I have tried netstat -ano on both the host and the vm and I cannot see any connection between the two.
I have tried turning off the firewall inside the virtual machine, just in case, but no success there either
Any suggestions.

Why is connection refused by Vagrant box in Windows 10?

I've been having problems with Vagrant since upgrading to Windows 10. At first I had the "host-only adapter" problem that many people seem to be experiencing. This was fixed by updating VirtualBox to the latest version, and my Vagrant box now seems to provision and start ok, and I can SSH into it, but can't connect via HTTP. If I try to access it from a browser, I get "Unable to connect". If I try curling it, I get the message:
Failed to connect to test.dev port 80: Connection refused
I've checked and Apache seems to be running on the VM (and in fact if I SSH into the VM and then run curl 127.0.0.1 the expected homepage is returned). At this point I've drawn a blank: I don't know whether the problem is in Windows or the VM's settings. Any help would be greatly appreciated!
(For what it's worth, I'm using VirtualBox 5.0.15r105158 + Vagrant 1.8.1)
Update: it turns out that the VM is accessible from test.dev:8888 in the browser, so I'm guessing the problem is to do with port-forwarding? I don't know much about this though, so have no idea why this wouldn't be working in Windows 10. (In case it helps, my Vagrantfile contains the line config.vm.network :forwarded_port, guest: 80, host: 8888)
I think you have answered all by yourself - you might read the vagrant doc on port forwarding
Vagrant forwarded ports allow you to access a port on your host
machine and have all data forwarded to a port on the guest machine,
over either TCP or UDP.
For example: If the guest machine is running a web server listening on
port 80, you can make a forwarded port mapping to port 8888 (or
anything) on your host machine. You can then open your browser to
localhost:8888 and browse the website, while all actual network data
is being sent to the guest.
when you add the line config.vm.network :forwarded_port, guest: 80, host: 8888 to your vagrant file, the VM (i.e. call also guest or guest VM) )will forward all the stream going on its port 80 to the host (in you case the windows machine) on port 8888, so in this case when you point your browser to listen on port 8888 you can see the website running from the VM
When you are within the VM though, you point to the expected 80 port.
one additional point (hope not to confuse you): in your Vagrantfile, did you define something for networking ? (param config.vm.network) you probably define a fixed IP (since you point to test.dev) in such case you dont need to do port forwarding, you can correctly access http://test.dev (on default port 80) as nothing else is bounding to this port. Port forwarding is really useful when you use public network and you do not define a fix IP to the guest VM, so in this case you access the site running on the VM from localhost/127.0.0.1, and as such you cannot just point to port 80, as something on your host can already be running.

Port forwarding on VirtualBox

I have to set up a Virtual Machine on vBox that works as a server for my app. Now, the app sends data to http://x.y.w.z:4567. I run apache server on host and wireshark confirms that the packet is received. Guest is behind NAT and is set up to forward TCPs from any IP port 4567 to port 443 on guest. I tried various versions of setting and not setting IP. Guest also has apache running, but it receives no packets. What should I do?
Please check the log that your port-forward rule is active. Also that your guest/host firewalls doesn't drop packets.