PhishFry is a python library and command line tool for removing and restoring emails in exchange and office365. PhishFry supports shared mailboxes, group mailboxes and distribution lists. PhishFry removes/restores the entire conversation including any replies and forwards of the message.
Install with pip directly from github.
sudo pip install git+https://github.com/ace-ecosystem/phishfry.git
Add credentials for one or more exchange accounts with impersonation rights to the config.ini file.
[account1]
[email protected]
pass=123456
[account2]
[email protected]
pass=123456
# display usage information
./phishfry.py -h
# Remove message with message_id=<message_id> from the [email protected] mailbox
./phishfry.py remove [email protected] "<message_id>"
# Restores message with message_id="<message_id>" to the [email protected] mailbox
./phishfry.py restore [email protected] "<message_id>"
import phishfry
# Instantiate a phishfry account using admin email and password
account = phishfry.Account("[email protected]", "123456")
# remove a message
results = account.Remove("[email protected]", "<message_id>")
# restore a message
results = account.Restore("[email protected]", "<message_id>")
# using the results
for address in results:
# print the email address for these results
print(address)
# get the remediation result for this address
result = results[address]
# print failure message if remediation action failed
if not result.success:
print(result.message)