Scapy - Script VS Command Line IPv6 Call - scapy

Trying to make a simple sr1 call to get an IPv6 address.
If I insert the command directly in scapy:
i = sr1(IPv6(dst="www.google.com")/ICMPv6EchoRequest())
print i.src
I'll have no error.
However, if I write that in a python script and then launch it, I get the error:
ERROR: [Errno -9] Address family for hostname not supported
I tried doing the same thing with IPv4 and it works just fine. How come?

Related

How to use python3 to connect to a ipv6 host using socket library

The following is my code in an attempt to connect to an IPv6 address host using sockets in python. However, all my attempts have resulted in the output "Network is unreachable". Could you point out what I am doing wrong and how it could be corrected?
import socket
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.connect(('2001:240:2408:8897:b4ac:9e51:ecc9:a388',8333,0,0))
OSError: [WinError 10051] A socket operation was attempted to an unreachable net
work
The only thing you did wrong is to give an IP address and port which is not reachable. It is also not reachable by other tools like telnet or netcat. The syntax itself is the correct one to connect to an IPv6 server. It will successfully connect if your for example replace the IP address with one for google.com and the port with 80 (http):
sock.connect(('2a00:1450:4001:81c::200e',80,0,0))

How to get the MAC address of remote raspberry using his ip address using python code

I am developing the ad-hoc network. I want to get MAC address of remote raspberry using his IP address.
I am doing this code
import sys,os
os.system ('sudo arp -n 115.0.0.2')
i am getting all things like hWthype, name of device and Flags Mask, HWaddress but i need only HWaddress
Can i body help me how I can extract only MAC address of remote raspberry using python code instead of cmd command?
you should use Grep command an catch MAC address with a regular expression to retrieve the line of the mac address.
Then use cut command to select only the address.
Post ifconfig output so we can help you better

RHEL Terminal Prompt is "unknown"

In my RHEL 7, my terminal prompt changes from localhost to UNKNOWN when I connect to the Internet. Why?
What you see at the prompt at the terminal is a name assigned by your DHCP Server appended by your MAC Address.
Try to search for dhclient.conf might be in /etc/dhcp
Edit the request statement and remove the host-name out of the list.
It should be like this
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers

Powershell Core "Couldn't resolve host name"

I'm using Powershell 6b5 AppImage on Arch Linux (using the official AppIimage). I have no trouble using IPv4 and IPv6 networking outside of powershell, both URL and IP. However, in PS, when I invoke the following command:
iwr 'http://google.com',
I get
iwr : Couldn't resolve host name.
I get the same error when I do the following (the IPv4 address is one of google.com)
iwr 'http://172.217.26.238'
Using the IPv6 address, I get a 404, which means that connection works fine:
iwr 'http://[2404:6800:4009:808::200e]'
Does anybody have any pointers on how to fix this?

emailrelay "cannot bind the listening port"

I'm setting up my web server on Amazon's EC2. My site used to run locally and used my ISP's SMTP server to send email, which hasn't been a problem before - but now that the emails are originating from outside my ISP won't accept them.
Therefore, I'm trying the advice here to use EmailRelay to forward emails, adding authentication, via my account on Google.
I've followed the instructions, created the emailrelay.auth file, run the configure, make, make install, but when I try to start the emailrelay service I'm getting this error:
$ emailrelay --as-proxy smtp.gmail.com:587 --client-tls --client-auth /etc/emailrelay.auth
emailrelay: error: cannot bind the listening port: 0.0.0.0:25
emailrelay: exception: cannot bind the listening port: 0.0.0.0:25
I've looked through the user guide, tried using the --interface option thinking this might be the issue - providing various IPs, with no joy - and I don't know what to try next.
(my server is running Oracle Enterprise Linux 5.1)
EDIT:
Since sendmail is running on port 25, I've tried an alternative port. Now I get a new error:
$ emailrelay --as-proxy smtp.gmail.com:587 --client-tls --client-auth /etc/emailrelay.auth --port 8025
emailrelay: error: cannot do tls/ssl: openssl not built in
emailrelay: exception: cannot do tls/ssl: openssl not built in
After killing sendmail, I've retried with port 25 and I get the same error ("cannot do tls/ssl: openssl not built in").
EDIT:
Looks like openssl is not installed:
$ grep ssl config.log
$ ./configure --with-openssl
configure:7373: checking for openssl
conftest.cpp:31:25: error: openssl/ssl.h: No such file or directory
| #include <openssl/ssl.h>
configure:7431: WARNING: ignoring --with-openssl, check config.log and try setting CFLAGS
config.status:719: creating src/gssl/Makefile
The error means that it can't gain exclusive access to port 25 (the default port for SMTP). This is either because it is already in use, or because, as an unprivileged user, you don't have access to ports numbered less than 1024.
There may already be a program running on port 25. Probably sendmail, but possibly postfix or qmail (I don't know what Oracle uses for mail). You will need to shut any such program down.
If you shut down any email software on the computer and run emailrelay as root, you will probably not get that error message.
I got to this question having the same issue on an EC2 instance running Ubuntu.
For Ubuntu:
first sudo apt-get install libssl-dev
then (re-)run ./configure && make && sudo make install
Now either using :25 if clear, or feeding another port to emailrelay --port 12345 it works as expected.

Resources