Saturday, April 27, 2013

Mikrotik DynDNS configuration how-to

,

Mikrotik is so powerful but unfortunately it doesn't support dynamic DNS service without using a script...
I had to create a full new config before some days so i was searching for the DDNS option but couldn`t find a thing.

So after our dear friend google there seems to be a script to bypass this limit:




# Set needed variables
:local username "yourusername"
:local password "yourpassword"
:local hostname "yourdyndnsorgname.dyndns.org"
:global systemname [/system identity get name]

:if ($systemname = "Site1" ) do= {
:set hostname "yourdomain1.dyndns.org"
}
:if ($systemname = "Site2" ) do= {
:set hostname "yourdomain2.dyndns.org"
}
:if ($systemname = "Site3" ) do= {
:set hostname "yourdomain3.dyndns.org"
}

:global dyndnsForce
:global previousIP

# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"

# Remove the # on next line to force an update every single time - useful for debugging,
# but you could end up getting blacklisted by DynDNS!

#:set dyndnsForce true

# Determine if dyndns update is needed
# more dyndns updater request details available at http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
src-path="/nic/update?hostname=$hostname&myip=$currentIP" dst-path="/dyndns.txt"
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}
After we save the script, we have to add a new scheduled job in the event which we just made with an interval of.. let's say... 15 minutes?

Now you can 'remote access' easily.
Read more →

Tuesday, April 9, 2013

Kali linux - No action for laptop lid

,
So i was trying to figure out the actions of my laptop's lid without going in a deep mode terminal way again..., after a long search nothing seemed to be working..., tried several tools but none of them were actually changing the action of the lid.
So after some days i came accross the gnome-tweak-tool which i've already used in the past and now turns out to be really helpful...

apt-get install gnome-tweak-tool | gnome-tweak-tool

Under Shell you should be able to find:
'Laptop lid close action on battery'
'Laptop lid close action when on AC'

Again, this is a bug found in some hardware, if you haven't found the option in the menu then try this.
Read more →

Useful console commands for Windows

,
Here is a list of console commands for almost any version of Windows:

Accessibility Options: access.cpl
Add Hardware: hdwwiz.cpl
Add / Remove Programs: appwiz.cpl
Administrative Tools: control admintools
Automatic Updates: wuaucpl.cpl
Wizard file transfer Bluethooth: fsquirt
Calculator: calc
Certificate Manager: certmgr.msc
Character: charmap
Checking disk: chkdsk
Manager of the album (clipboard): clipbrd
Command Prompt: cmd
Service components (DCOM): dcomcnfg
Computer Management: compmgmt.msc
DDE active sharing: ddeshare
Device Manager: devmgmt.msc
DirectX Control Panel (if installed): directx.cpl
DirectX Diagnostic Utility: dxdiag
Disk Cleanup: cleanmgr
Disk Defragmenter: dfrg.msc
Disk Management: diskmgmt.msc
Partition manager: diskpart
Display Properties: control desktop
Properties of the display (2): desk.cpl
Properties display (tab "appearance"): control color
Manager vérirficateur drivers: check
Event Viewer: eventvwr.msc
Verification of signatures of files: sigverif
Findfast (if present): findfast.cpl
Folder Options: control folders
Fonts (fonts): control fonts
Fonts folder windows: fonts
Group Policy: gpedit.msc
Internet Properties : inetcpl.cpl
IP Configuration: ipconfig
Keyboard Properties: control keyboard
Local Security Settings: secpol.msc
Local Users and Groups: lusrmgr.msc
Logout: logoff
Properties of the mouse: main.cpl // control mouse
Network Connections: ncpa.cpl
Notepad : notepad
Screen Keyboard: osk
Monitor performance: perfmon.msc
Power Options: powercfg.cpl
Printers and Faxes: control printers
Regional and Language Options: intl.cpl
Editor of the registry: regedit
Remote desktop connection: mstsc
Security Center: wscui.cpl
Console management services: services.msc
Shared folders: fsmgmt.msc
System Configuration Utility : msconfig
System File Checker (SFC =) (Scan Now): sfc /scannow
SFC (Scan next startup): sfc /scanonce
SFC (Scan each démarraget): sfc /scanboot
SFC (back to default settings): sfc /revert
SFC (purge cache files): sfc /purgecache
SFC (define size CAHC x): sfc /cachesize = x
System Properties: sysdm.cpl
Task Manager: taskmgr
Telnet client: telnet
Windows firewall: firewall.cpl
Windows Management Infrastructure: wmimgmt.msc
Protection of the accounts database: syskey
Date and Time Properties: timedate.cpl

Commands for scripting or fast editing some pesky things... hf.
Read more →

Sunday, April 7, 2013

Backup - Restore MySQL databases easily

,
As an IT there should be enough computers running MySQL which you would like to take care or maybe advantage easier than just looking around the fs without idea...
Let's say you hack into a system and all you do is their database! Hah, i am kiding, though, we would like to backup this database for security reasons.... How's the fast way? or How can we do this in a script?


Below are some commands that may be handy from time to time for those who doesn't already know..


Backup MySQL Database
# mysqldump -u(username) –p(password) (databasename) > (dumpfile.sql)

Backup all MySQL Databases
# mysqldump -u(username) –p(password) --all-databases > (dumpfile.sql)

Backup a Remote MySQL Database
 # mysqldump -h(hostip) -u(username) –p(password) (databasename) > (dumpfile.sql)

Restore MySQL Database
# mysql -u(username) –p(password) (databasename) < (dumpfile.sql)

Restore a database that already exist on the target machine
# mysqlimport -u(username) –p(password) (databasename) < (dumpfile.sql)
Read more →