Sendmail / Postfix - Testing mailserver

Links qmail.jms1.net BSD Handbook Sendmail.org This expects you to have netcat, perl and openssl installed Hello without TLS nc mail.server.com 25 220 mail.server.com ESMTP Sendmail 8.14.7/8.14.7; Thu, 11 Sep 2014 12:01:22 +0200 (CEST) > ehlo friendly.server.com 250-mail.server.com Hello friendly [1.2.3.4], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 250-STARTTLS 250-DELIVERBY 250 HELP > quit< 221 2.0.0 mail.server.com closing connection Hello with TLS openssl s_client -starttls smtp -crlf -connect mail.server.com:25 # ...Loads of text here... > ehlo friendly.server.com # ... Same as login without TLS (above) ... Test login $ perl -MMIME::Base64 -e 'print encode_base64("\000coolname\@iix.se\000my-password")' AGNvb2xuYW1lQGlpeC5zZQBteS1wYXNzd29yZA== # .. Log in to server with one of the above ... > AUTH PLAIN AGNvb2xuYW1lQGlpeC5zZQBteS1wYXNzd29yZA== 235 2.0.0 OK Authenticated > quit 221 2.0.0 mail.server.com closing connection Sending mail > mail from: <[email protected]> 250 ok > rcpt to: <[email protected]> 250 ok > data 354 go ahead > From: John <[email protected]> > To: Nobody <[email protected]> > Subject: fnord > > hail eris! > . 250 ok 1113954693 qp 29052 > quit

Ubuntu: Fix broken X11 after update

Updated my school ubuntu ws from raring to trust and X11 stopped working. Solution (2014) sudo apt-get remove --purge xserver-xorg sudo apt-get remove --purge nvidia* sudo apt-get autoremove --purge sudo reboot #..rebooting.. sudo apt-get install xserver-xorg sudo dpkg-reconfigure xserver-xorg # NB; nothing will seem to happen sudo reboot #..rebooting.. Now reinstall your favourite graphical environmnet Solution (2021) sudo apt purge nvidia* ubuntu-drivers devices # Manual option (install the one you want, start with "recommended") sudo apt install nvidia-driver-xxx # Automatic option sudo ubuntu-drivers autoinstall sudo reboot

September 5, 2014  | 

MySQL Cheatsheet

Starting mysql # Same username, no password mysql -p # Password protected mysql -u user mysql -h hostname Create user CREATE USER me GRANT ALL PRIVILEGES ON database_name.* TO 'me'@'%'; ALTER USER 'me'@'%' IDENTIFIED BY 'newPass'; Connect to databaes SHOW DATABASES; SHOW DATABASES LIKE 'ok%'; USE mysql; See database tables SHOW TABLES; SHOW TABLES LIKE 'ok%'; SELECT * FROM important_stuffs; Extend tables ALTER TABLE important_stuffs ADD description VARCHAR(100); ALTER TABLE important_stuffs ADD description VARCHAR(100) AFTER severity; ALTER TABLE important_stuffs ADD description VARCHAR(100) FIRST; Delete from tables SELECT * FROM important_stuffs WHERE severity="low"; DELETE FROM important_stuffs WHERE severity="low"; Insert into tables INSERT INTO important_stuffs VALUES("Wow, so important", "high"); INSERT INTO important_stuffs SET description="Wow, so important", severity="high"; Show access rights SHOW GRANTS; Change all email addresses to my (when mailserver is activated) UPDATE users SET email= CONCAT('me+', id, '@iix.se'); General log show variables like 'general_log%'; SET GLOBAL general_log = 'ON'; SET GLOBAL general_log = 'OFF'; Run query without cache SELECT SQL_NO_CACHE * from users where name like 'Ol%'; Indexes SHOW INDEX FROM users; ALTER TABLE users ADD INDEX index_name(firstName); CREATE INDEX index_name ON users(firstName); ALTER TABLE users DROP INDEX users; DROP INDEX index_name ON users; Explain/describe EXPLAIN users; DESCRIBE users; DESC users; DESC SELECT * FROM users; Profiling SET SESSION profiling = 1; SHOW PROFILES; SHOW PROFILE FOR QUERY 3; SHOW STATUS LIKE 'Last_Query_Cost'; Collation show variables like "collation_database"; SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA;

Syscalls

64 bits 32 bits 16 bits 8 bits rax eax ax al rbx ebx bx bl rcx ecx cx cl rdx edx dx dl rsi esi si sil rdi edi di dil rbp ebp bp bpl rsp esp sp spl r8 r8d r8w r8b r9 r9d r9w r9b r10 r10d r10w r10b r11 r11d r11w r11b r12 r12d r12w r12b r13 r13d r13w r13b r14 r14d r14w r14b r15 r15d r15w r15b Links 64-bit syscalls 32-bit syscalls

August 29, 2014  | 

C Programming Cheatsheet

Links Full ncurses manual Apple Secure Coding C Gibberish (Decode C declarations) Some C #define tricks Cannot find stdio.h (or other headers) Install libc6-dev Case insensitive str(n)cpy #include <strings.h> int strcasecmp(const char *s1, const char *s2); int strncasecmp(const char *s1, const char *s2, size_t n); xmalloc void *xmalloc(size_t size) { void *ptr = malloc(size); if (ptr == NULL) { fprintf(stderr, "%s: Virtual memory exhausted\n", progname); abort(); } return ptr; } xrealloc void *xrealloc(void *ptr, size_t newsize) { ptr = realloc(ptr, newsize); if (ptr == NULL) { fprintf(stderr, "%s: Virtual memory exhausted\n", progname); abort(); } return ptr; } C Operator Precedence Operator - Description - Associativity () - Parentesis - Left-To-Right [] - Brackets . - Object member -> - Object member -- ++ - Postfix increment/decrement -- ++ - Prefix increment/decrement - Right-To-Left - + - Unary plus/minus ! ~ - Logic negation/complement (type) - Cast * - Dereference & - Address sizeof - Get typesize * / % - Multiply/Divide/Modulo - Left-To-Right + - - Addition/Subtraction << >> - Bitwise shift < <= - Relation less/less or equal > >= - Relation more/more or equal == != - Relation (not) equal & - Bitwise AND ^ - Bitwise XOR | - Bitwise OR && - Logical AND || - Logical OR ?: - Ternary - Right-To-Left = - Assignment += -= - Add/Sub assignment *= /= - Mult/Div assignment %= &= - Modulo / Bitwise AND assignment ^= |= - Bitwise (X)OR <<= >>= - BITWISE SHL / SHR ASSIGNMENT

August 28, 2014  | 

Example SSH Config (.ssh/config)

To make it easier to ssh (and enable autocomplete), create a ~/.ssh/config like this: Host * SendEnv LANG LC_* HashKnownHosts yes GSSAPIAuthentication yes PreferredAuthentications publickey,password IdentityFile ~/.ssh/id_rsa ServerAliveInterval 60 Compression yes CompressionLevel 4 Host github Hostname github.com User git and you will always use user git when you ssh to github

August 28, 2014  |  🏷️Ssh

SSH Agent

If you has a rsa-key and don’t want to write in your credentials every time you ssh, you can use ssh-agent instead. Add this to your .bash_profile (or make it a standalone script you execute once at startup) SSHAGENT=$(command -v ssh-agent) SSHAGENTARGS="-s" if ! pgrep -xu $USER ssh-agent &>/dev/null; then if [[ -z "$SSH_AUTH_SOCK" && -x "$SSHAGENT" ]]; then eval "$($SSHAGENT $SSHAGENTARGS)" trap "kill $SSH_AGENT_PID" 0 fi fi Then you add you credentials once by typing ssh-add (which will add ~/.ssh/id_rsa, you can also add others) and write in your password. Now ssh-agent will automatically provide the password for you for the duration of the session. ...

August 28, 2014  |  🏷️Ssh

Sokoban Game

A small game I made in class

Crosh / HTerm

Go to nassh_preferences_editor.html under chrome extensions Change send-encoding from utf-8 to raw

Example of OpenBSD Postfix main.cf

# Global Postfix configuration file. This file lists only a subset # of all parameters. For the syntax, and for a complete parameter # list, see the postconf(5) manual page (command: "man 5 postconf"). # # For common configuration examples, see BASIC_CONFIGURATION_README # and STANDARD_CONFIGURATION_README. To find these documents, use # the command "postconf html_directory readme_directory", or go to # http://www.postfix.org/BASIC_CONFIGURATION_README.html etc. # # For best results, change no more than 2-3 parameters at a time, # and test if Postfix still works after every change. # Where is the postfix queue? queue_directory = /var/spool/postfix # Where are postXXX commands? command_directory = /usr/bin # Where are the postfix daemons? daemon_directory = /usr/lib/postfix/bin # Where is postfix-writeable data? data_directory = /var/lib/postfix # Who to run postfix as? mail_owner = postfix # What's my FQDN? myhostname = phii.iix.se # What's my domain name? mydomain = iix.se # Where are my mail sent from? myorigin = $mydomain # Which interfaces to I listen on? inet_interfaces = all # I think this is to which target's I email? mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain # How I reject mail (550 = reject mail, 450 = try again later) unknown_local_recipient_reject_code = 550 # Who do I trust? (I think this is forwarding or something) mynetworks_style = host # If you change the alias database, run "postalias /etc/aliases" (or # wherever your system stores the mail alias file), or simply run # "newaliases" to build the necessary DBM or DB file. # # It will take a minute or so before changes become visible. Use # "postfix reload" to eliminate the delay. alias_maps = hash:/etc/postfix/aliases # The alias_database parameter specifies the alias database(s) that # are built with "newaliases" or "sendmail -bi". This is a separate # configuration parameter, because alias_maps (see above) may specify # tables that are not necessarily all under control by Postfix. # What does this mean? Your guess is as good as mine alias_database = $alias_maps # Allow email tags # See canonical(5) local(8), relocated(5) and virtual(5) for effects recipient_delimiter = + # Debug level debug_peer_level = 2 # The debugger_command specifies the external command that is executed # when a Postfix daemon program is run with the -D option. # # Use "command .. & sleep 5" so that the debugger can attach before # the process marches on. If you use an X-based debugger, be sure to # set up your XAUTHORITY environment variable before starting Postfix. # debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 # If you can't use X, use this to capture the call stack when a # daemon crashes. The result is in a file in the configuration # directory, and is named after the process name and the process ID. # # debugger_command = # PATH=/bin:/usr/bin:/usr/local/bin; export PATH; (echo cont; # echo where) | gdb $daemon_directory/$process_name $process_id 2>&1 # >$config_directory/$process_name.$process_id.log & sleep 5 # # The full pathname of the Postfix sendmail command. sendmail_path = /usr/bin/sendmail # The full pathname of the Postfix newaliases command. newaliases_path = /usr/bin/newaliases # The full pathname of the Postfix mailq command. mailq_path = /usr/bin/mailq # setgid_group: The group for mail submission and queue management # commands. This must be a group name with a numerical group ID that # is not shared with other accounts, not even with the Postfix account. # setgid_group = postdrop # html_directory: The location of the Postfix HTML documentation. html_directory = no # manpage_directory: The location of the Postfix on-line manual pages. manpage_directory = /usr/share/man # sample_directory: The location of the Postfix sample configuration files. # This parameter is obsolete as of Postfix 2.1. but it feels nice to keep it sample_directory = /etc/postfix/sample # readme_directory: The location of the Postfix README files. readme_directory = /usr/share/doc/postfix # Protocol to use (I only have ipv4 so I can deploy it everywhere) inet_protocols = ipv4 ## Make sure we look in /etc/hosts first lmtp_host_lookup = native smtp_host_lookup = native # Fix issue with smtpd not finding certs smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt smtpd_tls_cert_file = /etc/postfix/ssl/newcert.pem smtpd_tls_key_file = /etc/postfix/ssl/privkey.key # Do I still need this? Yes? No? Maybe? compatibility_level = 2

December 30, 2013  |  🏷️Postfix