Skip to content

Margus Roo –

If you're inventing and pioneering, you have to be willing to be misunderstood for long periods of time

  • Cloudbreak Autoscale fix
  • Endast

Category: Linux

Dammit, kuradi vint raisk…

Posted on January 15, 2007 by margusja

Jan 15 18:49:20 juhe kernel: ata1: command 0x25 timeout, stat 0xd0 host_stat 0x21
Jan 15 18:49:20 juhe kernel: ata1: status=0xd0 { Busy }
Jan 15 18:49:20 juhe kernel: SCSI error : <0 0 0 0> return code = 0x8000002
Jan 15 18:49:20 juhe kernel: EOM ILI Current sda: sense = 70 69
Jan 15 18:49:20 juhe kernel: ASC=62 ASCQ=61
Jan 15 18:49:20 juhe kernel: end_request: I/O error, dev sda, sector 155
Jan 15 18:49:20 juhe kernel: Buffer I/O error on device sda1, logical block 23
Jan 15 18:49:20 juhe kernel: ATA: abnormal status 0xD0 on port 0xEC07

Ex n22b mis saab.

Posted in LinuxLeave a comment

Lihtsalt üks desktopi pilt

Posted on November 26, 2006 - November 26, 2006 by margusja

Ma ei tea mis kiiks on aga vahel harva tuleb isu oma desciga eputada. Sooooryyyyy.

Orininaalsuuruses siin

Posted in LinuxLeave a comment

FTP active and passive modes

Posted on November 23, 2006 by margusja

FTP is a TCP based service exclusively. There is no UDP component to FTP. FTP is an unusual service in that it utilizes two ports, a ‘data’ port and a ‘command’ port (also known as the control port). Traditionally these are port 21 for the command port and port 20 for the data port. The confusion begins however, when we find that depending on the mode, the data port is not always on port 20.

Active FTP

In active mode FTP the client connects from a random unprivileged port (N > 1023) to the FTP server’s command port, port 21. Then, the client starts listening to port N+1 and sends the FTP command PORT N+1 to the FTP server. The server will then connect back to the client’s specified data port from its local data port, which is port 20.

From the server-side firewall’s standpoint, to support active mode FTP the following communication channels need to be opened:
FTP server’s port 21 from anywhere (Client initiates connection)
FTP server’s port 21 to ports > 1023 (Server responds to client’s control port)
FTP server’s port 20 to ports > 1023 (Server initiates data connection to client’s data port)
FTP server’s port 20 from ports > 1023 (Client sends ACKs to server’s data port)

Passive FTP

In order to resolve the issue of the server initiating the connection to the client a different method for FTP connections was developed. This was known as passive mode, or PASV, after the command used by the client to tell the server it is in passive mode.

In passive mode FTP the client initiates both connections to the server, solving the problem of firewalls filtering the incoming data port connection to the client from the server. When opening an FTP connection, the client opens two random unprivileged ports locally (N > 1023 and N+1). The first port contacts the server on port 21, but instead of then issuing a PORT command and allowing the server to connect back to its data port, the client will issue the PASV command. The result of this is that the server then opens a random unprivileged port (P > 1023) and sends the PORT P command back to the client. The client then initiates the connection from port N+1 to port P on the server to transfer data.

From the server-side firewall’s standpoint, to support passive mode FTP the following communication channels need to be opened:
FTP server’s port 21 from anywhere (Client initiates connection)
FTP server’s port 21 to ports > 1023 (Server responds to client’s control port)
FTP server’s ports > 1023 from anywhere (Client initiates data connection to random port specified by server)
FTP server’s ports > 1023 to remote ports > 1023 (Server sends ACKs (and data) to client’s data port)

Summary

The following chart should help admins remember how each FTP mode works:
Active FTP :
command : client >1023 -> server 21
data : client >1023 <- server 20 Passive FTP : command : client >1023 -> server 21
data : client >1023 -> server >1023

A quick summary of the pros and cons of active vs. passive FTP is also in order:

Active FTP is beneficial to the FTP server admin, but detrimental to the client side admin. The FTP server attempts to make connections to random high ports on the client, which would almost certainly be blocked by a firewall on the client side. Passive FTP is beneficial to the client, but detrimental to the FTP server admin. The client will make both connections to the server, but one of them will be to a random high port, which would almost certainly be blocked by a firewall on the server side.

Luckily, there is somewhat of a compromise. Since admins running FTP servers will need to make their servers accessible to the greatest number of clients, they will almost certainly need to support passive FTP. The exposure of high level ports on the server can be minimized by specifying a limited port range for the FTP server to use. Thus, everything except for this range of ports can be firewalled on the server side. While this doesn’t eliminate all risk to the server, it decreases it tremendously.

Posted in LinuxLeave a comment

Arp spoofing

Posted on November 11, 2006 by margusja

Asja kohta palju manuaale. Aga v2hesed mainivad allolevaid iptables ridasid. Yksi ip_forward enablemisest ei piisa.

iptables –table nat –append POSTROUTING –out-interface eth0 -j MASQUERADE
iptables –append FORWARD –in-interface eth0 -j ACCEPT

echo 1 > /proc/sys/net/ipv4/ip_forward

Posted in LinuxLeave a comment

Creating the Cyrus-Imapd TLS/SSL Certificate

Posted on November 11, 2006 - August 26, 2011 by margusja

<code>

220 mail.okia.ee ESMTP Postfix (2.4.5) EHLO Margusjas-MacBook-Pro.local 250-mail.okia.ee 250-PIPELINING 250-SIZE 10240000 250-ETRN 250-STARTTLS 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN AUTH PLAIN AG1hcmd1c2phX29raWFfZWUAbWFyZ3VzamExMTI= 235 2.0.0 Authentication successful MAIL FROM:SIZE=695 250 2.1.0 Ok RCPT TO:250 2.1.5 Ok DATA 354 End data with.Message-ID: <4E57E252.9060107@okia.ee> Date: Fri, 26 Aug 2011 21:13:38 +0300 From: Margus RooUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: MargusjaSubject: test Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit — Margus Roo http://www.okia.ee —-BEGIN PUBLIC KEY—– MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD2KPM8YjdNO39TFgU+r5rDtiB8 OgqBHBDZTUDPu6zQDxV1t+Yt9uOmQ/RGRBapxqzedHFsBoYNjqH2bt9lMoy+jCaj +OLzY/NmOUZ2+HmsFHtDGpTcAUSIa3lygnSzgzXliDsH5YGXSXXOJULsk7FJdP82 AzssW9lhmz/Vk7NVAQIDAQAB —–END PUBLIC KEY—– . 250 2.0.0 Ok: queued as 0801911A8005 QUIT 221 2.0.0 Bye

</code>

 

openssl req -new -nodes -out req.pem -keyout key.pem
openssl rsa -in key.pem -out new.key.pem
openssl x509 -in req.pem -out ca-cert -req \
-signkey new.key.pem -days 999

mkdir /var/imap

cp new.key.pem /var/imap/server.pem
rm new.key.pem
cat ca-cert >> /var/imap/server.pem

chown cyrus:mail /var/imap/server.pem
chmod 600 /var/imap/server.pem # Your key should be protected

echo tls_ca_file: /var/imap/server.pem >> /etc/imapd.conf
echo tls_cert_file: /var/imap/server.pem >> /etc/imapd.conf
echo tls_key_file: /var/imap/server.pem >> /etc/imapd.conf

 

Nojah, kontrollida saad:

openssl s_client -connect mail.okia.ee:993 < IMAPS port

openssl s_client -connect mail.okia.ee:995 <  POPS port

Posted in LinuxLeave a comment

Vacation message & sivescript

Posted on October 25, 2006 by margusja

Create fail: (example: test.txt)
require “vacation”;
vacation :days {nr}:addresses “user@example.com”
“message”;

[root@server ~]# sieveshell –user=user –authname=authuser(cyrus) host
connecting to server
Please enter your password:
> put test.txt
> activate text.txt

Posted in LinuxLeave a comment

RCVD_DOUBLE_IP_SPAM Bulk email fingerprint (double IP)

Posted on September 15, 2006 - September 21, 2006 by margusja

two reliable signatures header __DOUBLE_IP_SPAM_2
Received =~ /from\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
\s+by\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3};/

Sellel kirjal on vähemalt kaks Received: päiserida milles teenindanud mailiserveri nimi on esitatud IP-aadressina.
See on üldiselt kahtlane ja sellepärast antakse selle eest kõrged punktid

Posted in LinuxLeave a comment

Minu avalikud võtmed

Posted on September 7, 2006 - January 22, 2007 by margusja

OKIA kontoris olev tööjaam:
sh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA31clV2J3R3yGtQTbxxyJSQw2J1DOod8vCbtUKpCMcYHPP6IxZSaWQ1rPqVP/5tqvRs3ruCuI3dFLf20ZlZjXgUllig3AZQ3MM0nAwPXroOkbzifm71x+9bO+u55YT1iLZAvihue/03mbnz/stV/dORzf51eWCW2oz7F64u09+rlya7Rp4ma/Cm5bbaMadm1NY43idB+tVWdbAh2Vki/8A8pcnZ2uzgYmk/qFejyfkaGxq5T8+pW+cW9gDWL27MEdvksAorEgZc0FXzVqYX+f2E+UIsXqtL+8jzyEOAU4j4iD81efnBw4Nf5e8roSxmRzWTIS/ZLO2nGbHWCxRQTQTQ== margusja@margusja.tank.ee

Läptop (Win):
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIBnMSdvlFlceatUhpOzj5WjCZ
c/6YdsIlLJEha3U9WPOKjsuWL0cK0lpq8xPRMdJOLVcQFRTxpY4S1gmQ
RHWCE7KA5bZtCCFYTFE8GtS3DPX/bqa6LLxccXNc8PvZgpsWx8ePR
pupPheN8IEstk1ldclBM3p3P3meZmKawjdQSGGw==

Läptop (Linux):
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAn+LgAyq49g2LM0ohALd
Z5eUGG10JWqssTxxKpQd4MhcWgn/5ma7nSs/0VY1VwIgyRQ0WCfDj
sqfcBWWulRyYIAtozWHhkE39rbr9GZFtvo5ZeT98nClXL4pbIsgntVaxM
H8O6HLIqfMM5IH84JOAUUKANVMFmVecZdt3lLP5QrwDY2Xxh+3sT6
bq28NMWcAa7fpsK1zU5mVcS a9FPH4RFaXGyAS+ULgFJxEB3bDdrX
BoHwFHGA4dxAyL8geOlkbY3X1J8FdlrP1OfJPIU+cs9rRN1OqN/esnlTS
aaL1+TgIv6aJg4nqMiShdFSg7+U/XdIJ1p3lUlbvRtNf1KAJR0Q== root@slax

Posted in LinuxLeave a comment

Joe & ~

Posted on September 7, 2006 - September 7, 2006 by margusja

Inimene on harjumuste ori, nii ka mina.
Olen aegade algusest peale kasutanud joe nimelist editori ja kavatsen kasutada ka edasi. Ilgelt cool editor minuarust, ainult teeb by default ~ lõppevaid backup faile, mis mõnesmõttes on nagu hea, aga turvalisuse mõttes paha paha ja noh läbu ka ikka.

Kuidas siis see asi välja lülitada.

~/.joerc faili esimeseks reaks: “-nobackups” või kui seda pole ja te olete root kasutaja siis failis /ets/joe/joerc

Posted in LinuxLeave a comment

Linuxi pudipadinurk

Posted on September 6, 2006 - October 12, 2010 by margusja

rekursiivselt asendamine

find . -type f -print0 | xargs -0 sed -i 's/oldstring/newstring/g' *.txt

  • hea saada cryptitud kujul parooli – echo parool | openssl passwd -crypt -stdin
  • sort /path/to/file | uniq – Juhul kui teil on tarvis eemaldada korduvread.
  • [12:13:52 root@h11 www]# ls -lah | awk ‘{print “chown root.root ./” $9 “/vhosts”}’ | sh – h11 suphp fedora 7 to fedora 9 upgrade abix
    • Kui kiiruga visata valmis Fedora install siis tõenäoliselt võib ununeda valida õige timezone. Lihtne võimalus seda hiljem seadistada on
      mv /etc/localtime /etc/localtime_orig
      ln -s /usr/share/zoneinfo/Europe/Tallinn /etc/localtime

      Ntp kasutades juhul kui kell on palju vale
      /etc/init.d/ntpd stop
      ntpdate -b tallinn-gw.bb.eenet.ee

      Kuupäeva ja kellaaja käsitsi seadistamine
      date –set=”07/16/2008 09:40:30″

    • Mõnus käsurida paljude ühte tüüpi failide õiguste muutmiseks: find -name “*.php” -print | xargs chmod 770
    • Kui tuleb häkker, selline kes armastab oma tööst jälgi jätta siis ta enamasti veebiserveris index.html failide kallal käib. Hea on siis välja sorteerida index.html failid kogu serveris: find / -mtime 0 -name “index.html” -print. -mtime 0 – muudetud täna, mktime -1 muudetud eila. Jne. Samas kui on teada muudetud faili suurus samuti, on abiks võti -size : find / -mtime 0 -size 7838c -name “index.html” -print
    • Ullult paar amavis, clamac installi hinti h6-te.

    amavise konfi kopeerisin monitorist ringi, seal olid ka varasemad h6 mingid ruulid sees
    aga clamav-update moodul tuli ka installida
    ja fresclamd konfe tuli kahes kohas muuta, et see tööle hakkaks
    ja kui see ei uuendanud, siis clamav ei läinud käima

    Parem hilja kui mittekunagi. Avastasin enda jaoks nc, siiani lihtsalt polnud vaja.
    target masinas paneme kuulama näiteks tarime midagi lahti: nc -l 7000 | tar xvf –
    source masinast hakkame saatma: tar -cvf – /home/ | nc 192.168.0.25 7000

    • rpm -ivh http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/5/freshrpms-
      release/freshrpms-release-1.1-1.fc.noarch.rpm – Fedora 5 kasutama freshrpm’i
    • openssl key and request:
      openssl genrsa -des3 -out server.key 1024 – Loome salajase võtme
      openssl req -new -key server.key -out server.csr – sertifikaadi päring
    • FC all hea mugav initisse panna. chkconfig service on
    • No vanainimene. Ei j22 meelde, et perlomooduleid saab ka installida: perl -MCPAN -e shell ja siis install module_name
    • Paar hinti cvs-i kasutamisest endale. Login – cvs -d :pserver:username@server:/repo_path login. Checkout – cvs -d :pserver:user@server:/repo_path checkout ./module_dir. Versiooni kustutamine serverist – cvs -d /repo_path admin -0ver.nr fail
    • export PGCLIENTENCODING=latin1
    • Juhtus selline lugu, et üks fail muutmise peale teatas et ta on readonly! WTF! Part on ok ja faili õigused ka ok.
      Häbi ütelda aga isegi restart sai masinale tehtud. Ei miskit.
      Abx lsattr ja chattr. ACL peal!
    • Suva mis kõvemad häkkerid kasutavad. Mina kasutan joe. Ja üks hint endale. Seal saab avada näiteks kaks taabi. Ja neid saab siis vahetada Ctrl-k p.
    • postfix ja error: relay access denied. Kontrollida kas /etc/postfix/relay_domains on vastav domain. Kui ei lisada ja postmap vastavale failile.
    • .forward ja mailikoopia – \\username, user@example.com
    • Kui ei viitsi pure-ftpd puhul eriti mingeid alternatiivseid auth. kohtasid leiutada ja teha ikka shellikasutajatega siis /etc/passw failis kodukataloogile lisada ./ – chroodib kenasti kasutaja oma kataloogi.
    • töötava kerneli conf: zcat /proc/config.g Uus kernel vana konfiga: zcat /proc/config.gz > .config; make oldconfig. Kindlasti ka make modules ja make modules_install
    • Kui cups-iga ei viitsi jamada siis hea moodus printeri lisamiseks on lpadmin käsk. lpadmin -p DisplayName -E -v socket://ip:9100 -P /paht_to/file.ppd. hiljem siis cups-i web GU-iga saab manageerida edasi.
    • Cd write in my debian workstation: cdrecord -v -eject speed=8 dev=ATAPI:0,0,0 file_to_cd
    • CD write in my Suse 10.2 workstation: /usr/bin/cdrecord -v gracetime=2 dev=/dev/hdc speed=40 -dao driveropts=burnfree -eject -data -tsize=307240s –
    • iptables (tulemüüri auk) Mudid /etc/sysconfig/iptables või mis iganes kohas asub iptables /etc/sysconfig/iptables – Salvestab, kuid ei soovita kasutada, kuna keerab iptables faili koledaks. Lihtsalt restardi iptables deemonit.
    • Linuxi shellis hea otsida failisisu järgi: find /path -exec grep -q “otsistring” ‘{}’ \; -print or grep -lir “string” /path
    • Kui juhtub et olete instaleerinud windooza ja mõne linuxi distro ühte masinasse eraldi ketastele ja boot loader asub windooza mbr peal. Juhtub, et teil on tarvis see win ketas eemaldada. Siis oleks hea kui teil oleks mõni linuxi installikas mille pealt annab teha linux rescue. Mina kasutasin FC1 installikat. Selle peale mounditakse teile kogu teie linux /mnt/sysimage. Soovitan teha chroot /mnt/sysimage, siis saate kasutada
      probleemideta grub-install /dev/teie linuxi ketas (hda|hdb jne…) Juhul kui te ei tee chroot siis ei leia grub-install grub k2äku pathist.
      Ok kui see õnnestub siis teete /boot/grub/menu.lst (minul ta siin ehk mõel teiselt distrol mujal)
      kataloogis asuvas menu failis vastavad muudatused.
    • Mehed raisk! mkfs.ext3 formatitakse!!! Nyyd ja alati!
    • Kui ipv6 ei kasuta ei ole mõtet masinat sellega ka piinata. Maha saab nii: ava /etc/modprobe.conf. lisa: alias net-pf-10 of. Järgmise boodiga ok.
    • Kui mailq on miskit paska täis, mis pole viimasel ajal ime: mailq | grep nimi@mail.ee | awk ‘{print $1}’ | sed s,*,,g | postsuper -d – ja postfix flush
    • Sattusin uue systeemi otsa. Loe pole minu installitud jne… Ok 20 sekundiga oli mailq 500 maili ühelt teatud maililt. Kiire hack: /etc/postfix/access faili teatudmailiaadres REJECT. main.cf rida: mtpd_client_restrictions = permit_mynetworks hash:/etc/postfix/maps/access. postmap /etc/postfix/access. Kindlasti on asjalikumaid lahendusi, kuid kui unine ja pohmas ja kliendid karjuvad kaelas siis ehk abx. Soovitav teha ka postsuper -r ALL et siis järjekorras olevad mailid läheks uuele ringile uute ruutingutega.
    • Kui kasutate linuxi all softraidi (Vaesed ajad, mis teha), siis soovitatav aegajalt tsekata raidi olukorda: /proc/mdstat, lsraid -a /dev/md1|2|3|..n Nonii, ja kui ühel hommikul (loe: koledal hommikul), avastate et midagi on mäda, ja üks raidis olev vint on lennanud. Otsite samasuguse või siis vähemalt sama suure vindi kui raidis oli. Katkine nahui ja uus asemele. Taastate fdisk nimelise tooliga partatsiooni tabeli. Vaatate /etc/raidtab failist kuidas mirrorid on ja raidhotadd progega lisate uued pardid uue vindi pealt mirrorisse (raidhotadd /dev/md? /dev/target_dev). Kui seal ei ole siis teed teed terve vindi järgi mdadm nimelise tooliga. mdadm –detail –scan selle väljundi lased siis näiteks /etc/raidtab.conf Kui see fail valmis võid panna sinna esimeseks reaks: MAILADDR root@firma.ee et siis mdadm –monitor –mail=sysadmin –delay=300 /dev/md{n} saaks sulle raidi katkiminemisest teatada. Siis lisad teise vindi pardid: mdadm –manage –add /dev/md{n} /dev/hd{a|b|c|d}{n} või mdadm –create /dev/md1 –level=1 –raid-devices=2 /dev/sd[ab]1  vastavalt sellele mis sul raidtab.confis on. Asjalik link: http://www.linuxdevcenter.com/pub/a/linux/2002/12/05/RAID.html. /etc/raidtab.conf ei ole uuematel distrodel enam vajalik.
    • Abiks on ka cat /proc/partitions – Kohe n2ha k6ik devaisid ja pardatsioonid.
  • Posted in LinuxLeave a comment

    Posts navigation

    Older posts
    Newer posts

    The Master

    Categories

    • Apache
    • Apple
    • Assembler
    • Audi
    • BigData
    • BMW
    • C
    • Elektroonika
    • Fun
    • Hadoop
    • help
    • Infotehnoloogia koolis
    • IOT
    • IT
    • IT eetilised
    • Java
    • Langevarjundus
    • Lapsed
    • lastekodu
    • Linux
    • M-401
    • Mac
    • Machine Learning
    • Matemaatika
    • Math
    • MSP430
    • Muusika
    • neo4j
    • openCL
    • Õpetaja identiteet ja tegevusvõimekus
    • oracle
    • PHP
    • PostgreSql
    • ProM
    • R
    • Turvalisus
    • Varia
    • Windows
    Proudly powered by WordPress | Theme: micro, developed by DevriX.