Oct 5, 2018

How I remotely found out the IP of my home computer after my ISP changed it.

I asked nicely 1 million machines if they were my computer. That's the short answer. Now for the long one:

I was using ssh to remotely work on my home machine. I was out for few weeks and the IP address only changes every few months, so I thought I was safe.

In reality it took less time for the IP to change. So I needed a plan...

Since I didn't setup a dyndns, or had anyone who could to tell me the new IP, I had to hack it out!

Fortunately I found a a list of the IPs used by each ISP in Portugal.


I then proceeded to fingerprint the machines.  I knew my machine had port 3000 open, so I needed to find machines with port 3000 open

sudo nmap -p3000 --open 5.43.0-63.1-254 5.158.0-63.1-254 5.249.0-127.1-254 37.28.192-255.1-254 46.189.128-255.1-254 77.54.0-255.1-254 78.137.192-255.1-254 83.174.0-63.1-254 87.103.0-127.1-254 89.114-115.0-255.1-254 93.108.0-255.1-254 94.60-63.0-255.1-254 95.136.0-127.1-254 148.63.0-255.1-254 148.69.0-255.1-254 148.71.0-255.1-254 149.90.0-255.1-254 161.230.0-255.1-254 178.166.0-127.1-254 188.37.0-255.1-254 212.18.160-191.1-254 213.30.0-127.1-254 -oN nmap_output.txt

I built this command that will analyse about ~1.000.000 IP addresses and figure out which have the port I want open, producing a list. This took about a day to complete.

It was then a matter of parsing the result. First I removed the RTT warning lines and got only the lines with IP addresses.

grep -v RTT nmap_output.txt | grep report > without_errors.txt

producing a list like this:

...
Nmap scan report for 11.11.11.11.rev.vodafone.pt (11.11.11.11)
Nmap scan report for 22.22.22.22.rev.vodafone.pt (22.22.22.22)
Nmap scan report for 33.33.33.33.rev.vodafone.pt (33.33.33.33)
...

I parsed this list to get just the IP addresses, using cut and a regex with sed.

cat without_errors.txt | cut -d' ' -f6 | sed "s/(//" | sed "s/)//" > only_ips.txt

Producing a list like this

...
11.11.11.11
22.22.22.22
33.33.33.33
...

And now I finally had a list which I could try to login into:

for i in $(cat only_ips.txt);do ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=2 -p22 $i "echo $i";done 2> /dev/null


And TADAM! I found my new IP address.

You could also first refine your fingerprinted result by finding machines that have another port open that you know to be open.

nmap -iL only_ips.txt -p2000 --open


I am sure there would be more efficient ways to do this, but I hope this can be useful to someone. :)

Apr 7, 2016

Ubuntu gaming. Make it faster. Fix for (steam) games being too slow on Ubuntu.

Feeling sad because your laptop is not fast enough to play Steam games on Ubuntu? Tried to use the 3rd party graphic card drivers and didn't feel any difference? Worry not, here's how to definitely improve game performance.

Getting ready: you should probably uninstall all third party drivers and reboot. Make sure you recently did an apt-get update and dist-upgrade.

Update the kernel.

Even with apt-get dist-upgrade, the kernel will not be updated to the latest available. In Linux, hardware support comes mostly from the kernel, and Ubuntu's kernel is way behind the main kernel branch. This is for stability and safety reasons. But you're not after stability, you want to get usage out of hardware. Update that kernel.  Here's how:
https://wiki.ubuntu.com/Kernel/MainlineBuilds

This step is basically just finding, downloading and installing 3 or 4 .deb files. Easy. 
I would recommend rebooting after this step.
Do uname -r before and after this step to confirm the new kernel version is in use.

Get the latest xorg. 

Instructions here. https://launchpad.net/~xorg-edgers/+archive/ubuntu/ppa. After adding this ppa you should do another apt-get update and dist-upgrade .

What we are doing here is getting the latest display server.

Test it out. 

It should probably be faster now. If you want, you can also try and go back to using the third party graphic/aditional driver to see if it makes things faster, now that you are using a more recent kernel. I didn't do this, but hey, experiment. :)


Note: I eventually tried this out. fglrx (ATI driver) for example needs older kernel versions. Careful then.

Feb 16, 2016

(Portuguese) Fazer stream rádio online para amigos


Para fazer isto basta ter o VLC Player instalado.

Vai-se fazer:

File-> Stream

Escolhe-se os ficheiros (não se pode adicionar outros ficheiros mais tarde sem reiniciar a rádio)

Clicar em stream

Nas opções selecionar http e editar. Meter uma porta diferente, por exemplo 7777.  Meter também um ficheiro, por exemplo /radio.ogg

Meter um ficheiro audio permite abrir a rádio com apenas um browser. Se bem que é preferível abri-la com um media player.

Activar o transcoding para diminuir a qualidade se necessário. Escolher um formato adequado e diminuir a qualidade do codec de audio. Baixar para 128 kbps por exemplo.

Experimentar abrir a rádio no browser ou num player com:

http://localhost:7777/radio.ogg

Para abrir externamente usar o ip externo em vez de localhost (fazer google: "what's my ip").

Nota: Se a rádio não funcionar é provavelmente porque a porta 7777 do router não está mapeada para a da máquina que está a fazer stream. Procurar como fazer port forwarding da porta 7777 para a porta 7777 da máquina local.

Jan 5, 2016

(Portuguese) Direitos

Direitos dos homens. Eis ao que se vergam as constituições.
Nesta versão moderna prevêem-se de forma subtil coisas de benefício duvidoso como: obrigatoriedade de existência dum estado social, direitos especiais para as mulheres, aceitação de estados policiais como norma, patentes, aceitação da subjugação do individuo à sociedade, e uma clausula final catita contra a negação futura de qualquer coisa que conseguiram por como direito. Para não falar da apropriação da definição de matrimonio (que estranhamente ainda é conservadora).
http://www.fpce.up.pt/sae/pdfs/Decl_Univ_Direitos_Homem.pdf

Gosto especialmente destas passagens:
«Artigo 19.º
Todo o indivíduo tem direito à liberdade de opinião e de expressão, o que implica o direito de não ser inquietado pelas suas opiniões e o de procurar, receber e difundir, sem consideração de fronteiras, informações e ideias por qualquer meio de expressão.»
-- Mas bora censurar? upset emoticon
«Artigo 12.º
Ninguém sofrerá intromissões arbitrárias na sua vida privada, na sua família, no seu domicílio ou na sua correspondência, nem ataques à sua honra e reputação. Contra tais intromissões ou ataques toda a pessoa tem direito a protecção da lei.»
-- Mas bora espiar? upset emoticon
-- Porque afinal todas as excepções ao acima podem ser justificadas com:
«Artigo 29.º
1. O indivíduo tem deveres para com a comunidade, fora da qual não é possível o livre e pleno desenvolvimento da sua personalidade.
2. No exercício deste direito e no gozo destas liberdades ninguém está sujeito senão às limitações estabelecidas pela lei com vista exclusivamente a promover o reconhecimento e o respeito dos direitos e liberdades dos outros e a fim de satisfazer as justas exigências da moral, da ordem pública e do bem-estar numa sociedade democrática.
3. Em caso algum estes direitos e liberdades poderão ser exercidos
contrariamente aos fins e aos princípios das Nações Unidas.»
-- Porque a tua interpretação dos teus direitos não importa, muchacho/a! like emoticon
A versão original parece-me melhor:
https://pt.wikipedia.org/…/Declara%C3%A7%C3%A3o_dos_Direito… squint emoticon
Assim como a constituição de PT, que ao menos prevê o direito legal à reacção à opressão:
3. Portugal reconhece o direito dos povos à autodeterminação e independência e ao desenvolvimento, bem como o direito à insurreição contra todas as formas de opressão.
Artigo 21.º
(Direito de resistência)
Todos têm o direito de resistir a qualquer ordem que ofenda os seus direitos, liberdades e garantias e de repelir pela força qualquer agressão, quando não seja possível recorrer à autoridade pública.
Yei, Portugal !!!

Oct 26, 2015

(Portuguese) Como fazer videos Youtube a partir de musica e uma imagem

Como pegar numa musica mp3 e numa imagem e rapidamente fazer um vídeo que se possa fazer upload para o youtube com bons resultados?


Versão rápida:

Em Linux, garantir que os pacotes mp3gain e ffmpeg estão instalados e correr o seguinte comando (atenção, o mp3gain altera permanente o volume do ficheiro de musica utilizado: se necessário fazer backup):

mp3gain -m 100 -k -r path_to_music_here.mp3 && ffmpeg -loop 1 -framerate 2 -i path_to_image_here.jpg -i path_to_music_here.mp3 -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p ~/output.mkv

E fazer upload do output para o youtube.

Versão extensa:

Usando o Linux precisamos de  dois pacotes instalados: ffmpeg e m3gain.

O uso do mp3gain não é estritamente necessário mas é bom para garantir a boa qualidade da musica quando ouvida no youtube.

O ffmpeg é que cria o vídeo. O site do ffmpeg é https://ffmpeg.org

Se os links abaixo tiverem partidos, tentar procurar no site oficial pelas localizações actuais.

Instalar o ffmpeg na sua versão mais recente:


Instalar o mp3gain:

A partir do Ubuntu 15, o mp3gain foi removido do repositorio por não ter sido actualizado.

Pode-se instalar o pacote com apt-get ou sacar o .deb:

O pacote está aqui http://packages.ubuntu.com/trusty/mp3gain . Pode-se instalar o pacote com dpkg -i pacote.deb ou procurar o binário compilado e extraír algures, mudando o comando para corresponder à localização do binário.

Escolher a combinação audio imagem:

Isto segue princípios básicos. Deve-se escolher uma musica de alta qualidade. Deve-se escolher uma imagem de alta qualidade. É educado ter autorizações para as duas ou que sejam de livre utilização. Pelo menos deve-se na descrição do vídeo referir o artista da musica e da imagem e suas respectivas homepage.

Normalizar o ficheiro audio:

mp3gain -m 100 -k -r path_to_music_here.mp3

Este comando faz o audio ficar o mais alto que puder sem ocorrer clipping.

Isto altera o ficheiro, portanto se se desejar  manter o ficheiro original, deve-se fazer backup e aplicar o mp3gain depois.

Criar o ficheiro vídeo:

Correr o seguinte comando:

ffmpeg -loop 1 -framerate 2 -i path_to_image_here.jpg -i path_to_music_here.mp3 -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p ~/output.mkv

Instruções retiradas daqui: https://trac.ffmpeg.org/wiki/Encode/YouTube
Convem consultar antes para verificar se permanecem actualizadas.

O que faz cada parametro, pode ser consultado no manual do ffmpeg. Há parametros que estão só no manual secundário do encoder (por exemplo no manual do encoder libx264).

Fazer upload para o youtube: 

Esta parte é fácil :)

Jun 15, 2015

Linux Adventures! Chapter Three: I'm Confused (Jun 2015)

Here's a list of misc stuff, more directed to confused Windows users.

A very basic Linux introduction for Windows users.


On Linux everything is a file. On Windows you are used to when opening the file explorer, to see the root as the partitions. And go from there. In Linux not so. Partitions are part of the main directory structure. But that directory structure is always the same. This can lead to some confusion, but you know *shrugs*. On Windows you got random file locations on different machines with different disks/partitions. Not so on Linux. You'll find the stuff where you expect to find it, and then have to figure out where it is physically. On Windows, a file's logical location is more random and a file's physical location more evident.


On Linux .exe doesn't mean anything. Executable is a property a file can have. Any file can be executable. The system you have (xfce, lxde, gnome) tries to guess what the file is based on the extension. But being executable is not related to the extension.

Easiest way to find cool Linux software to try out is to Google of course. But the fun way is to use Synaptic! Search it and be amazed.

How to install stuff without using the Software Center/Synaptic

To install stuff via command line is sometimes the easiest sudo apt-get install something

You can use the tab key to figure out the name of what you want to install. If you want to install something from the web, download the .deb file and install it with sudo dpkg -i file.deb


If installation involves running a file you have to go to it's location and do ./filename

But sometimes the file is not executable, so you have to do chmod +x  filename first.

How to play windows games and run windows applications on Linux

Easiest way to install and run windows stuff is an app called playonlinux. It supports loads of stuff. Install like any other app and check out the website for the supported stuff. The way it works: it makes a virtual disk with libraries to run your windows app in it, and it runs the windows installer inside that. It also has a way to install additional windows stuff inside, kinda like the way synaptic works. So you can install stuff like .net framework, directx, etc. If your app doesn't run you usually install some of that stuff and it starts running.


For example, there was a windows game I couldn't play online and all I did was install directplay in it's virtual drive, and then it started allowing online play :)



If you come from windows and have another question or something that confused you, post it on the comments, and I'll add it here!




Linux Adventures! Chapter Two: Making It All Work Better (Jun 2015)

Howdy partner!

This here is chapter two. If you are looking for chapter one, here ya go.

If not, let's continue.

So you got yourself a brand new installation of Linux. If you went along with the suggestion, you have Lubuntu. This guide assumes you did at least picked something similar to Lubuntu. If you didn't, good for you. This guide may still help you, but you will probably need more help.

Also, this guide assumes the machine is connected to the internet . If your wireless card is not working on Linux, this guide can help you. But you will still need to get stuff from the internet, either by connecting a cable or using another computer.

So what you should know?

Well, now I could teach you the basic stuff, or just go ahead and try to finish the installation. Or... do both at the same time. Bad for referencing, good for learning and that's what I am going to do.

So, let's finish the installation. Graphical interfaces are fine, but you need to know that sometimes typing the stuff you want is faster. And also, that most programs exist as command lines before existing as graphical interfaces.

Terminal!

Let's open a terminal. You can look for it in the start menu, (the windows key (called super key in Linux) won't work for that, use either Ctrl+Esc for the start menu) or... just click on the start menu with your mouse? :D


I don't want you to start by getting annoyed that the super/windows key does not work on Linux. The super key does work and does some cool stuff. Here, a quick reference you might want to browse through.

Back to how to open the terminal, you can also search for it by calling the run,  Alt+F2, and type stuff to find what you want. Or you can just use the fastest method besides creating a shortcut icon: Ctrl+Alt+T.

Done? A terminal should be open and ready to receive input.



One of the main advantages that Linux can have is the centralized updating system. This means that by using large online repositories, not only can you keep Linux updated, it will update the software you have installed, and the drivers you have installed. The only care you'll have to take is to install stuff from within the updating system, instead of downloading it and installing like you did in Windows (but you can do that too, of course).

We'll get there. Now, since we are finishing the installation, you should type this:

sudo apt-get update

and when that finishes:

sudo apt-get dist-upgrade

sudo means you are giving permission for the system to alter itself, which is necessary in this case. Everytime you do sudo you have to input your password.

This is what makes linux more virus proof. System changing stuff can't really happen without linux ask you for permission. The price to pay is having to input your password a lot.

apt-get is an application for installing stuff and updating the system.

dist-upgrade is an instruction for apt-get and it's telling it to upgrade everything. It's a more powerful (and some people say dangerous) form of upgrade, as in apt-get upgrade.

A tip: on a terminal you can use the Tab key to auto-complete as you type: try it, it's self explanatory.

So, you just formatted the  machine and already are downloading ~300MB of  updates? You betcha!

Continue only when the updates finish. Because you can't be updating the operating system from two sources at the same time.

Language support and restricted-extras!

Now, go to Start menu->preferences->Language Support


It will complain that Language Support is not fully installed. Why? I dunno, but just install it. Seems like a general Ubuntu annoyance. It will ask for your password after a while. And won't work but also won't complain if you are not online. Install any other languages you need. Check the regional format tab to see if it's the one you want.

Still not done. Now, you should go to the Lubuntu Software Center. I won't tell you where it is, find it, it's easy. There you'll find the restricted-extras and install them. These are some non-free codecs and some other stuff you probably want to have.

We done?

Nope, drivers.

Drivers!

If you are unlucky, stuff like your wireless card will still not be working. Go to Software Updater on the start menu, click on settings and fumble your way to the "Additional Drivers" tab. This thing is funny 'cause it won't ask for your password, and absolutely needs you to be online, but won't complain about you not being online, just fail silently. Also it takes a while to load but doesn't tell you how long.

Still, see the driver you need? If yes, try to install it. If not, you might want to install stuff later, so remember where this is. Some graphic drivers are better than the default free ones, and result in better graphics.

Careful now: drivers seem to be somewhat different from other normal packages that you can install using the software center or the apt-get. Why is this important? Because, if you manually download and install a driver from a website, while having another driver for that same device installed, you'll probably break your system somewhat (but not entirely: Linux is resilient).


If you didn't find the driver you need inside the Software Updater, you should use the Synaptic Package Manager. Which is kind of the real thing that let's you install and update your system. It's the graphical interface that the grandfather of Lubuntu, Debian, uses to install and update software. So you can expect it to be more powerful and lean, and a bit more overwhelming for newbies.

And guess what, except for the powerful dist-upgrade command, everything we did until now could have been done inside Synaptic. Welcome to Linux.

Inside Synaptic you should go to Settings->Repositories. On the first tab make sure everything is selected. Leave the source stuff as it is. On the second tab make sure Canonical Partners is selected.




If you are perceptive, you can see that this screen is the same as the "Settings" screen in the Software Updater we used earlier. I could just have brought you here directly, but I'm trying to show you what you should expect from Linux: lots of ways of doing the same thing.

Close the repositories, and click on reload. This is the equivalent to the sudo apt-get update command we used earlier.

After it finishes fetching the available stuff, you can use the search inside Synaptic to try and find the appropriate driver for your wi-fi card. For example, mine was a Broadcom, with the codename BCM, so I just searched for bcm and installed a bunch of stuff that seemed like it would make it. And BAM! it worked!(maybe after a reboot and/or going back to the additional drivers screen)


Funny thing, my Broadcom wireless card was working without any additional drivers. But it got way better reception after I found and installed its driver.

Again, try to install everything you can from inside Linux instead of downloading.

Are we done? Yes. Yes we are.

I'll now write the short-form protocol that one should take to finish a Ubuntu-type installation:

Short-form:

  1. Go to Synaptic Package Manager
  2. Go to the menu repositories, select all available repositories (except for source code and physical media ones). Let it update if it wants to. Close Synaptic
  3. Open a terminal and type: sudo apt-get update && sudo apt-get dist-upgrade . Let it finish. Close terminal
  4. Go to Language Support, it will complain that something is missing, let it install it. Install other Languages. Check regional settings. Close Language Support.
  5. Go to Synaptic Package Manager. You may need to install it first with sudo apt-get install synaptic
  6. In the repositories screen, switch to the additional drivers tab. Wait for it to populate.
  7. Select and install the drivers you want
  8. If a driver you need is missing from the additional drivers list, try to figure out the brand and model of the device. Go back to Synaptic and usually all you have to do is search for the model or brand name or codename, and the driver packages will show up. Install them. You may have to go back to the additional drivers screen to really install the driver
  9. Find and install your distro's restricted-extras package (example: lubuntu-restricted-extras)
  10. Close everything and reboot
  11. You might want repeat only step 3) at this time, and once a week in the future

Welcome to Linux, you noob :D

Jan 30, 2014

Windows Adventures! "Healthy and fast Windows for the lazy man."

You got your Windows.

You need to make it faster and harder to break down.

Here's what you need to keep in mind.

Use windows update, a lot, to keep your system up to date. But don't use it to update the drivers.
Use something like Drivermax or Slimdrivers to update your drivers. This type of software is usually not free, but these two have really good free functionalities.

Use a good program to clean the registry and compact it too if you have the time. I recommend JV16. It's not freeware but has a good trial.
Defragment your mechanical hardisk, don't defrag your non-mechanical hard disks.
Disable all the pretty stuff. Switch to the classic theme. Then go to control panel system and disable all visual effects (except for smooth fonts).

When gaming, consider using a game booster. I now recommend Wise Game Booster.

Other good tips for a fast machine.

If you are careful you don't need a real-time antivirus. Just get an on-demand free one, like ClamWinAV. An antivirus really slows down a system.
Consider switching your Windows to a Lite version of Windows. These are custom made, leaner versions of windows, that are around the web.

Update your BIOS or UEFI . Learn how to from the motherboard/laptop manufacturer and/or Google. This is dangerous, ask a friend if you can.

Disable all the devices (ex: IRQs) and any other stuff you don't need in the BIOS.
If you know for sure what type of hardware you have, tell the BIOS what it is, instead of letting the BIOS do the work (sometimes wrongly).

If you gonna try overclocking your machine make sure you have good ventilation. Overclocking sometimes is really worth it although a bit dangerous.

If your machine is slow one of the easiest ways to upgrade is to buy more memory for it, or sometimes a bigger hard disk or a SSD disk. Check if you need it and can. Buying a newer graphic card is also an option.

If all of these things don't help you even after formatting your machine, then you need a new computer.

Resumed steps:
  • Updated BIOS/UEFI 
  • Optimized BIOS/UEFI settings
  • Updated OS
  • Updated drivers
  • Optimized OS settings
  • Registry cleaner/compacter
  • Game booster

Linux Adventures! Chapter One: to Pick and to Install (Jun 2015)


linux mario
Hallo there!

This here two-part post will describe my current attempt at successfully discarding all my power-user knowledge of Windows and becoming a successful Linux guy.

Part one is about picking and installing. If you already did this, just go to part two, it's where the juice is.

So, ok! Here we go!

Picking your distro! 

 

Linux is cool cause you can see more of the stuff working, like a car that can turns its parts transparent whenever you want. "Whenever" is the key word for me. You may preach all you want, it still requires a bit too much information for Linux to be fun to use. And like all machines, it lies to you.

It starts with picking your Linux flavor. Too much choice! Not only that, there's also the legions of fanboys and guys that just want to belong to a club or show off their arbitrary skillzs. Eish... :(

From much reading I can now say the good easy and safe distros for newbies are Fedora, Debian, openSuse, and maybe Mageia. You then can pick variations of them, like Ubuntu, Mint or whatnot. Which in turn can have variations, like Lubuntu, Xubuntu. And then sometimes you can pick the graphical environment you want: Gnome, XFCE, LXDE.

lots of linuxesSo much choice. So, how to chose? Best way to chose, pick what your friends are using. Second best way to chose, pick the one that works for what you are going to use.

Most of my friends don't like Linux. I want to use Steam, some Windows applications and games, have good driver support, have a large user-base to draw knowledge from, lots of applications to try and use.




Also, I wanted a light graphical interface, but a non-distro specific one, so that I can eventually try other distros but keep the same interface.

So, until SteamOS stops being Beta, the logical choice would be Ubuntu LTS (long term, which usually means that it's a bit last year) and is the only distro officially supported by Steam. But yeah, I was not gonna do that. So instead, by looking around the logical choice I found the most recent Lubuntu. And if it works: close enough.

Installing your distro!


Installing Linux? Easy.

If you are on windows just Google the appropriate website. Choose between the 32bit or the 64bit version (32bit if you have 4GiB or less memory, else 64bit). Then you need to put that file you got into a pen that you can boot from. For that you need software. If you are on Windows use the universal usb installer.  On Linux there's a bunch of stuff, but for example, the Ubuntu family has its own way to do this, you can run the Usb Creator, or usb-creator-gtk.


So now you boot from the pen, if you don't know how to do this, ask a friend to do it. But it usually involves just pressing a key on the keyboard during computer startup and/or changing a setting inside the BIOS.

When you enter the installation, make sure you pick all the optional stuff. It doesn't hurt to have, it can hurt not to have.

The only part that can be problematic if you take the custom path is the partitioning.  I will now show my way of creating things for a single boot system (this means no Windows). Skip this step if it seems complicated and just select one of the default installation paths.

type     format  mount
primary  EXT4 -> root (or .)
primary  SWAP -> swap
extendable (and inside that):
extended EXT4 -> home

try understanding that text above by looking at this graph:


the partition I dedicate to the home folder gives me the ability to keep my stuff when I format (which on a non LTS version of Linux should be about once every 6 months). Speaking in Windows terms: it's like I reserved a special place in the hard disk for the My Documents folder, so I can upgrade easily and keep all my stuff.

If you want to take it slow and keep Windows, you should plan ahead when you install Windows and leave some space on your disk for Linux. And then you can install Linux on that empty space.

This is all for part one. When it finishes installing, it will seem ready but it ain't.

Welcome to Linux, newbie.
"Go back to Windows, you fruit-tart!"

Click here for Linux Adventures: Chapter Two: The art of making it all work better.


fullmooninu, 2014
images by their respective  creators
mario-tux by santang