Python Exchange ActiveSync Library - python

Is anyone familiar with an Exchange ActiveSync library or open source client for python? I've done preliminary searching with little to no success. I've seen some examples for C#, but I figured I'd ask around here before my attempt to port anything over.
In case you're curious. This would be an extension of an already existing linux based IMAP / POP3 client. Moving to Windows / C# this late in the game isn't really an option.

On Debian 9:
apt-get install mercurial python-twisted
hg clone https://bitbucket.org/drspringfield/py-eas-client
cd py-eas-client
python setup.py install
python imap_to_eas_proxy.py --domain example.org --server mail.example.org --device_id myID.example.net
then connect via insecure IMAP to localhost:3143 and log in as normal. (For the Exchange server I was trying to connect to, this just threw Activesync error Connection lost, but it might work on other Exchange servers and/or when py-eas-client is improved.)

Related

Quick start with SCAPY and WIRESHARK (Including drivers) (Custom WIFI Packets) [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 1 year ago.
Improve this question
Scapy with WIFI - From setup to use
This tutorial is supposed to help you through the setup and installation of scapy and the wifi dongle used in this tutorial.
WIRESHARK, PYTHON AND SCAPY
I spent some time with scapy and want to share my knowledge since there are lots of spots where things can go wrong. I am using the TP-Link wifi dongle TL-WN722N V2.
Operating System:
I found that first of all you need to install your own driver to be able to use frame injection and monitor mode. Windows is not an option here because monitor mode was depreciated in earlier versions. Next I tried linux.
As I am quiet new to linux myself I played around a little and found out that most tutorials on WIFI monitor mode are only working for kali linux, which is fine if you want to use it for hacking. Another operating system for which I can confirm the drivers working is Ubuntu (version 20.04.2 currently). I also tried installing the drivers on raspbian. It does not work, ubuntu server version can be installed on raspberry pi, though. I hope this saves you some trouble.
=> Use Kali or Ubuntu (desktop and server version both work for ubuntu)
Installing The Driver
After reading the above paragraph this should be quiet easy as all the tutorials made for kali linux also work for ubuntu. Below are the steps that I took to install everything:
sudo apt update
sudo apt install bc make gcc
sudo rmmod r8188eu.ko
git clone -b v5.2.20 https://github.com/aircrack-ng/rtl8812au.git
cd rtl8812au
sudo -i
echo "blacklist r8188eu" > "/etc/modprobe.d/realtek.conf"
exit
make
sudo make install
sudo modprobe 8188eu
The most common error for me appeared after calling make. This is often due to wrong kernels and can be fixed by switching to ubuntu or kali as this has to do with the operating system.
Do not forget to reboot before the next steps.
Turn On Monitor Mode
This is also somewhat difficult because, as for me even though using the same operating system on rpi and my desktop computer, errors appeared at different spots. My solution was to simply fiddle around with the code and just trying random combination, leading me to success.
It is important that you use iwconfig to determine the name of your wifi dongle
Use these commands
ifconfig wlan0 down
airmon-ng check kill //Only useful in some situations
usermod -a -G netdev USERNAME //In case the operation is not permitted even though you are root
iwconfig wlan0 mode monitor //On RPi simply use this command without turning wlan0 down
ifconfig wlan0 up
iwconfig //Check out whether you have been successful and the mode says 'monitor' now
No idea why it does not always work the same way but your are very likely to succeed with the above commands.
Using Scapy
Finally, the fun stuff. Get ready to use pip to install scapy (python3 -m pip install scapy). Sadly, scapy only supports Python up to version 3.8, so make sure to have the correct version installed and activated as your default python. You also might need to run the script as root.
The code for sending packets is very straight forward:
from scapy.all import *
conf.use_pcap = True //Not quiet sure if this is optional
send(IP(dst="0.0.0.0")/UDP(dport=123, sport=200)/Raw(load="I am WIFI"), iface="wlan0", loop=1, inter=0.2)
I am not really trying to make a tutorial on how scapy itself works, only the big picture and how to set it up. It is a very interesting library and you should definitely check it out.
Most errors will arise from the import as it is crucial to use the proper python version! Also, the similar methods send() and sendp() troubled me a lot. I was unable to pick up anything with wireshark useing the sendp() method using the same parameters as above.
The iface="wlan0" is responsible for selecting the interface via which the packets are send. It should be matching with the interface you found earlier with the iwconfig command and set to monitor mode.
Using Wireshark
Wireshark is an awesome tool for prototyping whatever you want to do. If something is not working you should start looking there first. You can use it to identify what you are sending by running Wireshark on the transmitting wifi dongle or use another wifi dongle to pick up your packets. If you have done everything correctly and run the python script, while recording with Wireshark, you should be picking up many of the "I am WIFI" messages.
Thank you for going thorugh all of this. I hope I saved some people from all-nighters trying to figure out kernels, drivers or version mismatching.
Do ask me questions.

Pinging without calling system commands

I need a way to ping remote machines without calling system commands. And if possible, without admin or root access. Something that could work on any platform.
I had a quick look into python3 -m pip install pyping but importing it returns me the following :
ModuleNotFoundError: No module named 'core'.
Also it require root/admin access which I would like to avoid.
How should I proceed ?
An ICMP Ping is a "special" kind of networking that uses a raw socket. I don't super understand it myself, but TLDR is that it seems difficult to do without privilege escalation.
If you know for a fact a given TCP port on the target machine(s) are going to be open, you can just try to establish a TCP connection to that port. For example, if you can SSH into these machines, the standard SSH port (22) is usually open. You don't need to actually communicate - just establish a TCP connection to that port then drop it. See TcpCommunication
this is because the module was introduced for python 2,however if you want to use it with python3 you can manipulate it or use 2to3 module,this question was asked in unable to import pyping for python3

Mesos - Zookeeper error; Connection Refused

I've set up Apache Mesos 0.21.2 on a virtual machine. The installation was performed by downloading the sources, compiling it and applying make install.
On another virtual machine I've copied the build directory in order to use it as a slave system.
I wanted to start with a small 'hello world' framework as showed in http://jamesporter.me/2014/11/15/hello-mesos.html
however, when I'm executing the python framework with
python hello_mesos.py
I get the following log:
I1227 19:16:02.790803 1678 sched.cpp:137] Version: 0.21.1
2015-12-27 19:16:02,790:1678(0x7f6b1e3de700):ZOO_INFO#log_env#712: Client
environment:zookeeper.version=zookeeper C client 3.4.5
...
2015-12-27
19:17:09,526:1678(0x7f6b1bf7e700):ZOO_ERROR#handle_socket_error_msg#1697:
Socket [127.0.0.1:2181] zk retcode=-4, errno=111(Connection refused): server
refused to accept the client
What can be the source that triggers this error? Is there any other way to get more information?
Thank you in advance for any hints and
with best regards
I'd recommend that you use a recent Mesos version, 0.21.2 is quite old as 0.26.0 is out. There are also precompiled packages available.
Concerning your actual problem, it appears that either
ZooKeeper is not started on the host you're trying to execute your framework on
If you're trying to reach ZK from another host, you need to set the actual IP

mysql-python mac OSX 10.10 disable secure auth

Working on a python app on Mac (Yosemite OSX 10.10) I ran into this issue:
OperationalError: (2049, "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)")
With a bit of research it seemed that my client (that is mysql-python) is using secure auth and the user had a password encrypted in an old style, that is prior to pre-4.1.1.
As I do not have ways to handle things on the DB side I was wondering if there was a workaround or a way to deactivate secure_auth on mysql-python?
I am adapting the answer from here:
Eventually you have to tell the client who has an old-style password to change it to a new-style password. Old passwords are not secure.
Now, you are getting the error since the client has secure_auth set, but they have an old password. In order to login with the old password, the client must disable secure_auth on the client side. How exactly you do this varies by which client you're using.
Some other workarounds can be found in the MySQL documentation: Client does not support authentication protocol
I found a cure!
Or rather a workaround. From this post I decided to select slightly older version of MySQL and MySQLdb and this solved the issue.
Here is how I did it:
I had previously installed mysql_python for my python and had the brew version of mysql installed.
I deteleted all of that.
I look for a way to install MySQLdb by looking for it last stable version with the source.
I compiled them (followed the isntructions here), installed them and then I looked for a stable version of MySQL client (MySQL website is the best place for that) and install the 5.5 version which was perfectly fitting my requirements.
I made mysql to launch itself automatically and then restarted my computer (but you can just restart apache) and check that all path were correct and the right includes are in the right places (you can check that against the link above).
And now it all works fine!
Hope it helps.

SSH and SCP from windows with Python 3

I've Been stuck here for days. I want to copy a file from my windows to a remote linux server and run the script there. I've tool for ssh and scp. from which I can call the linux server through command line but when I call it through python it gets hanged.
pro=subprocess.Popen('ssh user#server')
pro.communicate()
there is a blank screen. whatever I type then after appear to my screen.
I was hoping there should be a password prompt but there isn't any. I thought of using library like paramiko, pexpect, pyssh but none of them are supported in Python 3
Any help is highly appreciated.
http://docs.fabfile.org/en/1.0.1/index.html
I'm not sure it can be converted by 2to3
but it's rather simple to use:
from fabric.api import run, env
from fabric.context_managers import hide
from fabric.colors import green
with hide('status', 'running', 'output'):
print('Apache ' + env.host + ': ' + green(run('wget -q -O /dev/null http://localhost/ && echo OK')))
env.host comes from command line, twisted couch is another alternative but it's not yet ported to py3k
There was another question like this. Use netcat. 'man nc'. Use os.system() in python to spawn it on both client side and server side.
From the netcat manual page:
DESCRIPTION
The nc (or netcat) utility is used for just about anything under the sun
involving TCP or UDP. It can open TCP connections, send UDP packets,
listen on arbitrary TCP and UDP ports, do port scanning, and deal with
both IPv4 and IPv6. Unlike telnet(1), nc scripts nicely, and separates
error messages onto standard error instead of sending them to standard
output, as telnet(1) does with some.
Common uses include:
simple TCP proxies
shell-script based HTTP clients and servers
network daemon testing
a SOCKS or HTTP ProxyCommand for ssh(1)
and much, much more
This works great for both local or remote machines on an intranet and also internet if aware of the related issues (original question did not specify the meaning of 'remote'). Some examples are:
http://www.sans.org/security-resources/sec560/netcat_cheat_sheet_v1.pdf
"Netcat - The TCP/IP Swiss Army Knife - SANS"
http://www.sans.org/reading_room/whitepapers/tools/netcat-tcp-ip-swiss-army-knife_952
Note that sans.org teaches both foundational comp sci tools and security.
http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/ ; Note this example includes complete automated backup via netcat: "Netcat is extremely useful for creating a partition image and sending it to a remote machine on-the-fly"
http://www.stearns.org/doc/nc-intro.v0.9.html ; An example for making dirt simple remote logging.
As for the comment "but that isn't python": Don't reinvent the wheel when there are very good foundational utilities which have been ported to all O/Ss and have no other dependencies other than the underlying base O/S.

Categories