Author Topic: telnet localhost 110 and read email and telnet 143 imap style  (Read 8062 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
telnet localhost 110 and read email and telnet 143 imap style
« on: มกราคม 23, 2011, 10:25:25 PM »
pop00:/home/golf/___script___# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Hello there.
user golfs@example.com
+OK Password required.
pass PASSGU
+OK logged in.
LIST
+OK POP3 clients that break here, they violate STD53.
1 1326
2 467
.
RETR 1
+OK 1326 octets follow.
Return-Path: < postmaster@example.com>;
Delivered-To: golfs@example.com
Received: from ldap00.xx.com (ldap00.th.xx.com [10.17.200.22])
by pop00.xx.com (Postfix) with ESMTP id D4B374C8069
for < golfs@example.com>;; Tue, 10 Nov 2009 17:57:00 +0700 (ICT)
Received: from ldap00.xx.com (localhost [127.0.0.1])
by ldap00.xx.com (Postfix) with ESMTP id F14376DF824
for < golfs@example.com>;; Tue, 10 Nov 2009 17:57:00 +0700 (ICT)
Received: (from www@localhost)
by ldap00.xx.com (8.14.3/8.14.3/Submit) id nAAAv0NL085397;
Tue, 10 Nov 2009 17:57:00 +0700 (ICT)
(envelope-from postmaster@example.com)
Date: Tue, 10 Nov 2009 17:57:00 +0700 (ICT)
X-Authentication-Warning: ldap00.xx.com: www set sender to postmaster@example.com using -f
To: golfs@example.com
Subject: Welcome to xx mail service
Message-ID: < 1257850620883_36a8e9eb903b074f4fa6ca13c8395ab9@116.68.150.233>;
X-Mailer: Phamm
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: < postmaster@xx.com>;


Welcome to ddd service!
-----------------------------------------------

Dear users,

Thank you for using ddd service.

Please kindly consider change your password periodically for your security.



.
quit
+OK Bye-bye.
« Last Edit: มกราคม 24, 2011, 11:26:22 AM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: telnet localhost 110 and read email
« Reply #1 on: มกราคม 23, 2011, 10:26:08 PM »
#!/bin/bash

####++ReadME++####
# 1.Input username and password to userlist.txt #
# xxx@xxx.com password #
# 2.Run this script and see output in check_command.txt#
#


export PATH=/usr/sbin:/sbin:/usr/bin:/bin:/usr/local/bin
HOME=/home/golf/check_telnet
echo > ${HOME}/check_command.txt
#xxx=`( echo user ${usernamex}; sleep 1; echo pass ${passwordx}; sleep 1; echo quit)`

if [ -s ${HOME}/userlist.txt ]
then
xx=`less ${HOME}/userlist.txt | wc -l`
echo "All accounts = ${xx}"
while read usernamex passwordx
do
( echo user $usernamex; sleep 1; echo pass $passwordx; sleep 1; echo quit ) | telnet
localhost 110 >> ${HOME}/check_command.txt
echo "check $usernamex" >> ${HOME}/check_command.txt
echo "" >> ${HOME}/check_command.txt
echo "" >> ${HOME}/check_command.txt
done < ${HOME}/userlist.txt
echo /dev/null > ${HOME}/userlist.txt
else
exit
fi
#( echo $USER; sleep 1; echo $PASS; sleep 1; echo exit ) | telnet abc.com


zz=`less ${HOME}/check_command.txt | grep "+OK logged in." | wc -l`
yy=$xx-$zz
expr $yy

echo "==================================================="
echo "Wrong password = $yy accounts"
echo "==================================================="
echo "Run this command below"
echo "less ${HOME}/check_command.txt"

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: telnet localhost 110 and read email and telnet 143 imap style
« Reply #2 on: มกราคม 24, 2011, 11:26:31 AM »
วิธีการเข้าไปอ่านเมลผ่าน protocol imap (port 143) ด้วยวิธีการ telnet
#telnet localhost 143

ขั้นตอนที่ 1 ทำการใส่ username password ตาม command
. login user@test.com password

ขั้นตอนที่ 2 ทำการ list ดูรายชื่อ folder ภายใน account ของเรา
. LIST "INBOX" "*"
* LIST (\HasNoChildren) "." "INBOX.Folder1"
* LIST (\HasNoChildren) "." "INBOX.Folder2"
* LIST (\HasChildren) "." "INBOX.Folder3"
. OK Completed

ขั้นตอนที่ 3 ทำการ select folder ที่ต้องการเข้าไปอ่านเมล
. SELECT "INBOX"
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen NonJunk Junk $NotJunk $Junk $Forwarded)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen NonJunk Junk $NotJunk $Junk $Forwarded \*)] 
* 2 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1136990532]
* OK [UIDNEXT 12498]
* OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox
. OK [READ-WRITE] Completed

ขั้นตอนที่ 4 หลังจากพบว่ามีเมลอยู่ใน inbox อยู่ 2 ฉบับ (2 EXISTS) และต้องการอ่านเมลฉบับที่ 2 ก็
. FETCH 2 BODY []

Return-Path: <root@example.com>
X-Original-To: golftest
Delivered-To: golftest@example.com
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
        by spz.example.com (Postfix) with SMTP id 6B9E49F78B
        for <golftest>; Thu, 30 Apr 2015 09:57:03 +0700 (ICT)
Message-Id: <20150430025706.6B9E49F78B@example.com>
Date: Thu, 30 Apr 2015 09:57:03 +0700 (ICT)
From: root@example.com
To: undisclosed-recipients:;

check send second on 0954
)
* 2 FETCH (FLAGS (\Seen \Recent))
. OK FETCH completed.

ขั้นตอนที่ 5 หลังจากเจอ mail content แล้วต้องการจบ process และ logout ออก
. logout
« Last Edit: เมษายน 30, 2015, 10:10:59 AM by golfreeze »