Find SMTP Open Relays with SWAKS

I recently discovered I had an open mail relay. This situation was particularly frustrating because tools like mxtoolbox kept reporting my mail server as not having an open relay. All the standard tools simply looked at failure to issue commands as evidence that relay access was denied, when in fact that was NOT the case!

The clue that the “Not an open relay” message was a lie was in the details. Instead of a message about “access denied” the tool returned 530 5.7.0 Must issue a STARTTLS command first [205 ms]

I was only able to finally get confirmation about my open mail relay from SWAKS. It really is a wonderful tool. This is the command that finally cracked the case for me:

swaks --to user@domain.com --server mail.domain.com   --from support@domain.com --port 587 -tls --tls-protocol tlsv1_2

This resulted in a successful unauthenticated e-mail sent from my domain. The open relay was used TLS on port 587, which was opened to allow end users to be able to send mail from their devices. This was made possible thanks to an SSH tunnel I had set up to send port 587 on the external IP directly to the internal mail server, not realizing this would treat all traffic to that IP as trusted.

I’ve closed all that up to prevent any more incursions. It is quite interesting that I had that open for quite some time before someone decided to try to relay using TLS on port 587, and that none of the standard web tools reported it as an open relay!

Pipe mysql export from a docker container into a different docker container

I recently needed to take a mysql database export from one docker container and import it into a different docker container. It took a while to get the commands I needed, with this stackoverflow thread helping me to understand what needed to be done.

I initially tried to use docker exec -it <container> /bin/bash but when I tried to pipe a mysqldump to a mysql to another container I kept getting cannot attach stdin to a TTY-enabled container because stdin is not a terminal

I tracked that down to the -t option of docker exec. Once I removed that I was able to pipe the dump successfully!

sudo docker exec -i <SOURE_MYSQL_CONTAINER> mysqldump -u <USER> -p<PASSWORD> <DATABASE_TO_DUMP> | sudo docker exec -i <DESTINATION_MYSQL_CONTAINER> mysql -u<DESTINATION_DATABASE_USER> -p<DESTINATION_DATABASE_PASSWORD> <DESTINATION_DATABASE>