SSL/TLS find Insecure Connection in VPN Project [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed yesterday.
Improve this question
I write a custom vpn project in python using TUN/TAP interface and UDP Socket connection for my self, and its work fine and every data that comes from the tun will encrypt and will goes through the udp connection securly and in server side comes from UDP and its decrypt and then sends to TUN interface.
in both side ethernet NAT with the TUN and in client its connect to my local.
All Pings transfer completely and all NAT works fine in server and client.
but when i want to open a google website or other websites, browser says ssl/tls insecure connection.
how it can findout this? and whats the way to solve this?
I test the websites from deferent computer in my local network and its not my browser or clock problem.
I know it is the problem of my project or NAT rules, but i dont know where it is?
I test my connection and NAT rulse and all of them works fine, and ping the google website through the VPN transfer completly.
I can ping everywhere but i cannot open any website because of ssl/tls insecure connection.

Related

How to make a port forward rule in Python 3 in windows? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Purpose:
I'm making a program that will set up a dedicated server (software made by game devs) for a game with minimal effort. One common step in making the server functional is port forwarding by making a port forward rule on a router.
Me and my friends have been port forwarding through conventional means for many years with mixed results. As such I am hoping to build a function that will forward a port on a router when given the internal ip of the router, the internal ip of the current computer,the port and the protocol. I have looked for solutions for similar problems, but I found the solutions difficult to understand since i'm not really familiar with the socket module. I would prefer not to use any programs that are not generally installed on windows since I plan to have this function work on systems other than my own.
Approaches I have explored:
Creating a bat file that issues commands by means of netsh, then running the bat.
Making additions to the settings in a router found under Network -> Network Infrastructure (I do not know how to access these settings programmaticly).
(I'm aware programs such as GameRanger do this)
Using the Socket Module.
If anyone can shed some light how I can accomplish any of the above approaches or give me some insight on how I can approach this problem another way I would greatly appreciate it.
Thank you.
Edit: Purpose
You should read first some sort of informations about UPnP (Router Port-Forwarding) and that it's normally disabled.
Dependent of your needs, you could also try a look at ssh reverse tunnels and at ssh at all, as it can solve many problems.
But you will see that working with windows and things like adavanced network things is a bad idea.
At least you should use cygwin.
And when you really interessted in network traffic at all, wireshark should be installed.
I'm not sure if that's possible, as much as I know, ports aren't actually a thing their just some abstraction convention made by protocols today and supported by your operating system that allows you to have multiple connections per one machine,
now sockets are basically some object provided to you by the operating system that implements some protocol stack and allows you to communicate with other systems, the API provides you some very nice API called the socket API which allows you use it's functionality in order to communicate with other computers, Port forwarding is not an actual thing, it just means that when the operating system of the router when receiving incoming packets that are destined to some port it will drop them if the port is not open, think of your router as some bouncer or doorman, standing in the entrance of a building, the building is your LAN, your apartment is your machine and rooms within your apartment are ports, some package or mail arrives to your doorman under the port X, a port rule means on IP Y and Port X of the router -> forward to IP Z and port A of some computer within the LAN ( provides and implements the NAT/PAT ) so what happens if we'll go back to my analogy is something such as this: doorman receives mail destined to some port, and checks if that port is open, if not it drops the mail if it is it allows it to go to some room within some apartment.. (sounds complex I know apologize) my point is, every router chooses to implement port rules or port blocking a little bit different and there is no standard protocol for doing, socket is some object that allows you program to communicate with others, you could create some server - client with sockets but that means that you'll need to create or program your router, and I'm not sure if that's possible,
what you COULD do is:
every router provides some http client ( web client ) that is used to create and forward ports, maybe if you read about your router you could get access to that client and write some python http script that forwards ports automatically
another point I've forgot is that you need to make sure you're own firewall isn't blocking ports, but there's no need for sockets / python to do so, just manually config it

Multiple clients from same IP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
If you have a service that uses a specific port, and you have multiple computers on the same ip addess, how is this handled? Should the service specify to which computer on the ip address the information should be send? What if both computers on the same ip use the same service, but request different information?
Also, if a client is on a dynamic ip, how should the service detect that the ip has been changed, but the client (and the session) is the same? Should clients identify themselves for every request (much like cookies over http)?
You have many questions, I'll try to respond to them one by one.
If you have a service that uses a specific port, and you have multiple computers on the same ip addess, how is this handled?
Someone mentioned that multiple computers cannot have the same IP address. In the original IP model, this is true, though today such address sharing (through NAT) is common. But even in the original model, your question makes sense if you reformulate it slightly:
"If you have a service that uses a specific port, and you have multiple clients on the same ip address, how is this handled?"
There can be multiple client processes on the same host (thus sharing the same IP address) trying to contact the same server (using the same destination address+port combination). This was natural at the time IP was developed, as most machines powerful enough to connect to the network were multi-user machines. That's why TCP (and UDP) have port numbers on both sides (source and destination, or client and server). Client processes typically don't specify the source port when contacting a server, but an "ephemeral" source port is allocated to the socket by the host operating system for the lifetime of the socket (connection). So this is how the server distinguishes between clients from the same address: by their source ports.
NAT maps different hosts (with different "internal" IP addresses) to the same "external" IP addresses, but it also allocates unique source ports to outgoing packets. So the server sees this just like the original case (multiple client processes from the same "host"/IP address). The NAT then "demultiplexes" the server's responses to the different internal hosts.
Should the service specify to which computer on the ip address the information should be send? What if both computers on the same ip use the same service, but request different information?
The server does this by sending responses to the same address+port combination that the different clients used as source address/port. This is mostly handled automatically by the socket API. As described above, the two clients will get separate connections, and the server hopefully handles these as separate "sessions" and doesn't confuse requests between these sessions.
Also, if a client is on a dynamic ip, how should the service detect that the ip has been changed, but the client (and the session) is the same? Should clients identify themselves for every request (much like cookies over http)?
Now, this is a whole can of worms. If a service wants to "survive" client IP address changes, then it will have to use some other identifier. HTTP (session) cookies are a good example. TCP connections are broken by address changes - this is normal, as such changes weren't envisioned as part of normal operation when TCP/IP was designed. There have been attempts at making TCP/IP more robust against such changes, such as Mobile IP, MPTCP, and possibly SCTP, but none of these have really entered the mainstream yet. Basing your protocol on HTTP(S) and using session cookies may be your best bet.
I don't think I fully understand what you've said. There is no way that multiple computers will be on the same IP, this is not how the internet works.. There are protocols which hadels such things.
Did you mean that you're a server and multiple computers try connect to you?
If so, you listen in a port and when you get a connection you open a new thread for the service of that computer and the main loop still listening

How do I code a USB-TCP relay? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to be able to read and write with a USB port from a remote machine as if it were local. I want to do this by writing a python script that establishes a TCP connection to the remote machine and then constantly reads from the USB port and write to the TCP connection and vice versa. What is the best way to code this up in Python simply and quickly?
I had to do the same thing you're asking for a robotics project I had in the past year. We had a Raspberry Pi constantly reading on a USB port linked to an Arduino board, and as soon as it got some message it sent it throught TCP to all the remote clients connected.
The project is called autonomee and is available on github.
To summarize, you have to do the following:
The 'client' connects to the server that is linked to the USB "source"
Have a thread (on the server) constantly reading from the USB (I'd recommend using pyserial or pyusb for that)
When you receive some data, send it throught TCP to the remote client (more on that below)
The remote client keeps listening for data and whenever it gets a message it processes it
The most thought part is the TCP connection, and it's not that hard.
You can either use twisted for a higher level TCP server or just use the standard TCPServer class (we did the latter). Check the examples on the SocketServer doc, they are really useful !
I can't give you much more detail as it highly depends on which kind of data you have to send, at which frequency, but I'd advise you to have a look at the code I've produced for the server and the client

python tcp over http emulation

What's the easiest way to establish an emulated TCP connection over HTTP with python 2.7.x?
Server: a python program on pythonanywhere (or some analogue) free hosting, that doesn't provide a dedicated ip. Client: a python program on a Windows PC.
Connection is established via multiprocessing.BaseManager and works fine when testing both server and client on the same machine.
Is there a way to make this work over HTTP with minimal additions to the code?
P.S. I need this for a grid computing project.
P.P.S. I'm new to python & network & web programming, started studying it several days ago.
Found this: http://code.activestate.com/recipes/577643-transparent-http-tunnel-for-python-sockets-to-be-u/. Appears to be exactly what I need, though I don't understand how to invoke setup_http_proxy() on server/client side. Tried setup_http_proxy("my.proxy", 8080) on both sides, but it didn't work.
Also found this: http://docs.python.org/2/library/httplib.html. What does the HTTPConnection.set_tunnel method actually do? Can I use it to solve the problem in question?
Usage on the client:
setup_http_proxy("THE_ADRESS", THE_PORT_NUMBER) # address of the Proxy, port the Proxy is listening on
The code wraps sockets to perform an initial HTTP CONNECT request to the proxy setup to get an HTTP Proxy to proxy the TCP connection for you but for that you'll need a compliant proxy (most won't allow you to open TCP connections unless it's for HTTPS).
HTTPConnection.set_tunnel basically does the same thing.
For your use case, a program running on free hosting, this just won't work. Your free host probably will only allow you to handle http requests, not have long running processes listen for tcp connections(which the code assumes).
You should rethink your need to tunnel and organize your communication to post data (and poll for messages from the server, unless they're answers to the stuff you post). Or you can purchase a VPS hosting that will give you more control over what you can host remotely.

how to set a proxy for python email client [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Recently I am studying email-related and have written a simple mail client to send emails.
But unfortunately due to the bad network I can not connect to smtp.gmail.com home. It is OK when I use a proxy in the browser, also OK when the script is run in company.
So are there any methods to set a proxy for smtp protocol? I don't see anything I can use in the smtplib module in Python2.7. And I think it is of no use to set the http proxy. They are two kinds of protocols. I have also searched Google and stackoverflow and can not find a reasonable resolution.
So, it seems there is a socket proxy. Is that useful?
Hope somebody could tell me something.
Install a local mail server which maintains its own mail queue like Postfix. Your own, local mail server actually is a caching SMTP-proxy, so exactly what you want to do. Your local application will deliver its mail to Postfix which makes sure the mail gets delivered to the actual recipient. There are lots of other mail servers doing this job totally fine, too.
Setting up Postfix is out of scope for an SO-Answer (or ServerFault, I guess it gets migrated), but there are lots of tutorials round there (and it depends on the machine you're using). Setting up postfix to use Gmail as smarthost will be of interest for you, too, as it involves some smaller hassles with certificates.

Categories