# Trouble with multiple weak passwords in flows

**URL:** <https://forum.suricata.io/t/trouble-with-multiple-weak-passwords-in-flows/1244>\
**Category:** Help\
**Tags:** rules\
**Created:** [March 23, 2021, 9:27am UTC](https://forum.suricata.io/t/trouble-with-multiple-weak-passwords-in-flows/1244 "2021-03-23T09:27:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kimo](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kimo](https://forum.suricata.io/u/kimo)\
**Post date:** [March 23, 2021, 9:27am UTC](https://forum.suricata.io/t/trouble-with-multiple-weak-passwords-in-flows/1244/1 "2021-03-23T09:27:16Z")

</div>

Hi everyone!  
I want to catch username and password in a flow.  
In this case, flowbits and pcre are needed, such as

> alert tcp any any → any 110 (msg:“get pop3 info”;  
> content:“USER”; nocase;  
> pcre:“/USER\s+([^\r\n]+)\r\nPASS\s+([^\r\n]+)\r\n/i, flow:username, flow:password”;  
> flowbits:set, pop3\_info;noalert;  
> sid:200020; gid:10001;)

> alert tcp any 110 → any any (msg:“get pop3 status”;  
> flowbits:isset, pop3\_info;  
> pcre:“/[±](ERR|OK)\s+(?:Authentication|authorization|Logged in.)\s+(?:failed)?[^\r\n]\*?\r\n/, flow:status”;  
> flowbits:unset, pop3\_info;  
> target:src\_ip;sid:200028; gid:10001;)

I can catch username and password successfully if there’s only one login behavior in the flow.  
However, if multiple login, I can only catch the first username in a flow.

Meanwhile, In order to grab multiple data I try using `flowbits: unset xxx`, `flow:stateless`, `pcre:/xxxx/, pkt:name, pkt: pass` , but it doesn’t work.

Could you guys give me some advice?

Thx in advance

---

<div class="post-metadata">

**Author:** ![kimo](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kimo](https://forum.suricata.io/u/kimo)\
**Post date:** [March 23, 2021, 9:34am UTC](https://forum.suricata.io/t/trouble-with-multiple-weak-passwords-in-flows/1244/2 "2021-03-23T09:34:11Z")

</div>

Pics associated

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/suricata/original/1X/0063526218c514aa66c5e859e3abff9efdfd38a9.png)

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/suricata/original/1X/b5d296f4a8b4cae29b7677a48744a896d7e2bf26.png)

---

<div class="post-metadata">

**Author:** ![kimo](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kimo](https://forum.suricata.io/u/kimo)\
**Post date:** [March 24, 2021, 10:31am UTC](https://forum.suricata.io/t/trouble-with-multiple-weak-passwords-in-flows/1244/3 "2021-03-24T10:31:29Z")

</div>

The above rules are demo things. There’re the real rules of SMTP below

> alert smtp any any → any 25 (msg:“get smtp username”; \   
> flowbits: set, smtp\_login;\   
> pcre:“/AUTH LOGIN\r\n([\w]+={0,2})\r\n([\w]+={0,2})\r\n/i, flow:username, flow:password”;noalert;\ sid:200010; gid:10001;)

> alert smtp any 25 → any any (msg:“get smtp status”;\   
> flowbits: isset, smtp\_login;priority:1;  
> flowbits: unset, smtp\_login;  
> pcre:“/(235|535).\*\r\n/, flow:status”;\   
> target:src\_ip; sid:200019; gid:10001;)

and packets for test

[smtp\_test.pcapng](https://forum.suricata.io/uploads/short-url/ttnR4Y5DIdB3HwVWTT4SqWl7zLT.pcapng) (13.3 KB)

Thx for your help

---

<div class="post-metadata">

**Author:** ![syoc](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@syoc](https://forum.suricata.io/u/syoc)\
**Post date:** [March 24, 2021, 12:06pm UTC](https://forum.suricata.io/t/trouble-with-multiple-weak-passwords-in-flows/1244/4 "2021-03-24T12:06:29Z")

</div>

Seems like you want to use signatures for logging.  
Can you enable smtp logging in suricata and get the data you want from there instead?

---

<div class="post-metadata">

**Author:** ![kimo](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kimo](https://forum.suricata.io/u/kimo)\
**Post date:** [March 25, 2021, 2:04am UTC](https://forum.suricata.io/t/trouble-with-multiple-weak-passwords-in-flows/1244/6 "2021-03-25T02:04:16Z")

</div>

Thank you for reply! But I just want to grab data and process the data in another Process which with algorithm that give a judgement to weak passwords
