$ sudo sh -c "echo 0 > /proc/sys/kernel/randomize_va_space"
Thursday, May 24, 2012
How to disable ASLR in Linux
Quick note to self on how to disable ASLR (address space layout randomization) in Ubuntu Linux:
Did you just email me back my own password?!
A while ago I wrote a blog post about what precautions to take handling password data on your website. plaintextoffenders.com is a website dedicated to this issue. It nicely points out why storing passwords in plaintext really is such a bad idea. The main part of the website is a pillory of submitted websites which obviously apply bad password practices. There's for awareness...
Thursday, April 26, 2012
Seven Languages in Seven Weeks - Prolog Day 2 Self-Study
More fun with prolog! This self-study section consists in implementing some list operations.
Reverse the elements of a list
Find the smallest element of a list.
Sort the elements of a list.
Reverse the elements of a list
rev([], []). rev([Head|Tail], List) :- append(X, [Head], List), rev(Tail, X).
Find the smallest element of a list.
min([X], X). min([Head1|[Head2|Tail]], X) :- Head1 =< Head2, min([Head1|Tail], X). min([Head1|[Head2|Tail]], X) :- Head1 > Head2, min([Head2|Tail], X).
Sort the elements of a list.
insert(X, [], [X]). insert(X, [H|T], [X,H|T]) :- X =< H. insert(X, [H|T], [H|Rest]) :- X > H, insert(X, T, Rest). isort([], Acc, Acc). isort([H|T], Acc, Sorted) :- insert(H, Acc, Acc2), isort(T, Acc2, Sorted).
Wednesday, April 25, 2012
Seven Languages in Seven Weeks - Prolog Day 1 Self-Study
For this book's section about prolog, I'll be using SWI-Prolog, as I'm currently getting an error installing the gnu-prolog macport. Here's the link to the SWI-Prolog online reference.
Make a simple knowledge base. Represent some of your favorite books and authors.
Find all books in your knowledge base written by one author.
Make a knowledge base representing musicians and instruments. Also represent musicians and their genre of music.
Find all musicians who play the guitar.
Make a simple knowledge base. Represent some of your favorite books and authors.
% books.pl book(sevenLanguagesInSevenWeeks). book(cleanCode). book(cleanCoder). book(programmingInScala). author(odersky). author(tate). author(martin). wrote(odersky, programmingInScala). wrote(tate, sevenLanguagesInSevenWeeks). wrote(martin, cleanCode). wrote(martin, cleanCoder).
Find all books in your knowledge base written by one author.
?- ['books']. % books compiled 0.00 sec, 13 clauses true. ?- wrote(martin, X). X = cleanCode ; X = cleanCoder.
Make a knowledge base representing musicians and instruments. Also represent musicians and their genre of music.
% music.pl instrument(flea, bass). instrument(hendrix, guitar). instrument(hancock, piano). instrument(cash, guitar). genre(flea, funk). genre(hendrix, blues). genre(hancock, jazz). genre(cash, country).
Find all musicians who play the guitar.
?- ['music']. % music compiled 0.00 sec, 10 clauses true. ?- instrument(X, guitar). X = hendrix ; X = cash.
Wednesday, April 4, 2012
How to get a List of Installed JVMs on a Mac
I got this tip from a fellow worker:
$ /usr/libexec/java_home -VThis command will get you the list of installed Java Virtual Machines installed on your Mac OS X system.
Sunday, April 1, 2012
Inspecting the Process Environment Variables with GDB
While trying to solve the 4th level of the vortex wargame, I found it was necessary to learn how to inspect the location and content of the environment variables within the process memory.
GDB has built-in commands to inspect the process environment, see the GDB manual. You can either list all environment variables or a specific one (e.g. FOOBAR) using the following commands, which will output their values:
I also found these links to be useful:
GDB has built-in commands to inspect the process environment, see the GDB manual. You can either list all environment variables or a specific one (e.g. FOOBAR) using the following commands, which will output their values:
(gdb) show environment (gdb) show environment FOOBARIn order to locate the environment variables within the process memory, you can query the variable char** environ (see the libc reference and this entry on stack overflow):
(gdb) x/s *((char **)environ)This will print the location of the first environment variable and its representation as string. To print the next variables, simply add an offset to the variable:
(gdb) x/s *((char **)environ + 1)
I also found these links to be useful:
Wednesday, March 28, 2012
Seven Languages in Seven Weeks - Io Day 3 Self-Study
It's been some time now, still I'm keeping up reading Seven Languages in Seven Weeks. Here's the last self-study section about the Io programming language.
Enhance the XML program to add spaces to show the indentation structure.
Create a list syntax that uses brackets
Enhance the XML program to handle attributes: if the first argument is a map (use the curly brackets syntax), add attributes to the XML program. For example: book({"author": "Tate"}...) would print <book author="Tate">.
Enhance the XML program to add spaces to show the indentation structure.
Builder := Object clone
Builder numIndents := 0
Builder doIndents := method (for (i, 1, numIndents, write(" ")))
Builder openTag := method(name, doIndents; writeln("<", name, ">"))
Builder closeTag := method(name, doIndents; writeln("</", name, ">"))
Builder forward := method (
openTag(call message name);
numIndents = numIndents + 1;
call message arguments foreach (
arg,
content := self doMessage(arg);
if (content type == "Sequence", doIndents; writeln(content))
);
numIndents = numIndents - 1;
closeTag(call message name)
)
Builder ul(
li("Javascript"),
li("Lua"),
li("Javascript")
)
Create a list syntax that uses brackets
squareBrackets := method(call message arguments)
Enhance the XML program to handle attributes: if the first argument is a map (use the curly brackets syntax), add attributes to the XML program. For example: book({"author": "Tate"}...) would print <book author="Tate">.
OperatorTable addAssignOperator(":", "atPutNumber")
Map atPutNumber := method(
self atPut(
call evalArgAt(0) asMutable removePrefix("\"") removeSuffix("\""),
call evalArgAt(1)
)
)
curlyBrackets := method(
map := Map clone;
call message arguments foreach(arg, map doMessage(arg));
map
)
Builder := Object clone
Builder numIndents := 0
Builder doIndents := method (for (i, 1, numIndents, write(" ")))
Builder doAttributes := method(map, map keys foreach(key, write(" ", key, "=\"", map at(key) ,"\"")))
Builder forward := method (
doIndents; write("<", call message name);
if(call message arguments size == 0, writeln(">"));
numIndents = numIndents + 1;
call message arguments foreach (i, arg,
content := self doMessage(arg);
if (i == 0,
if(content type == "Map", doAttributes(content));
writeln(">")
)
if (content type == "Sequence", doIndents; writeln(content));
);
numIndents = numIndents - 1;
doIndents; writeln("</", call message name, ">")
)
Subscribe to:
Posts (Atom)