fixed: handle all optional cookies for given domain #1155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This quick fix makes it possible, in the absence of authorization URL, to mark all cookie tokens as optional for a given
domain
while having other mandatory tokens, that is http or body tokens, or even non-optional cookie tokens for anotherdomain
.Code analysis:
In the edge case where all cookie tokens are optional and no authorization URL is provided, Evilginx will indeed never consider the session as finished since
AllCookieAuthTokensCaptured
will always returnfalse
. This is because thetcopy
array will contain from the start (firstfor
) an empty array which will never be deleted (secondfor
). In the absence of authorization URL, Evilginx currently stores sessions in the database only if this function returnstrue
at some point, which means in this case, sessions will not be displayed even though all mandatory tokens have been captured.Example:
Without the fix:
![image](https://private-user-images.githubusercontent.com/67361113/402724413-66ba68ec-c0da-4f65-aef9-424df23422d9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1ODA0MjIsIm5iZiI6MTczOTU4MDEyMiwicGF0aCI6Ii82NzM2MTExMy80MDI3MjQ0MTMtNjZiYTY4ZWMtYzBkYS00ZjY1LWFlZjktNDI0ZGYyMzQyMmQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDAwNDIwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk1MGVlNWYzYjA0ODRmNWU2ZGJiZDMxYTY0NTg1MjcwN2Y0MmE1YmQ2MGQxZmMwYTJlNjI1NThhYzVlMzY3NTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.TUSrlc8ZDH-bnXnWkScHvK_wqnUW78fZYsKw5kFlNks)
With the fix:
![image](https://private-user-images.githubusercontent.com/67361113/402726132-05051629-50cd-4aad-b255-47cfbc9f0e0b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1ODA0MjIsIm5iZiI6MTczOTU4MDEyMiwicGF0aCI6Ii82NzM2MTExMy80MDI3MjYxMzItMDUwNTE2MjktNTBjZC00YWFkLWIyNTUtNDdjZmJjOWYwZTBiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDAwNDIwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQyMWZiZmZjM2M4MjIwMTk2NThkMDI1NGRkNjU5YzljYWIyMjA2YTBkZTU4YzA1ZmNjYTk5MjRjZWUwMTNlODMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.TD5bV9dKje8TUK0yRxr1aaLMmFRBJUp5yaoKf4kz8L4)
NB: In this case, the optional cookie is delivered before the (mandatory) body token, which is why we see it displayed in the session information. If it had been delivered after the body token, it wouldn't have been displayed at all:
In this last case, the only way to capture the optional cookie is to use an authorization URL.