Pages

Tuesday, December 13, 2011

XSS techniques: defeat a target that only escapes single and double quotes

I assume that you found an entry point either, from
  1. the url
  2. an injectable
    <input .../>
  3. or a form input, find functions on certain websites are very exploitable
Assume that the target accepts injections with slashes and escapes only single and double-quotes as a security measure:

Try to break the webpage with '-->', e.g. html comment termination,
inject your payload, e.g. <script>...</script>

Escaping double and single quotes:

a.
(new String(1)).replace((new Number(1)).toString(10), /look no single or double quotes/);

b.
String.fromCharCode(n1, n2, ..., nX)

c. replace (for compression)

Use this python snippet to prepare the payload:

[ ord(c) for c in "http://payload_in_decimal" ]

The drawback of this technique is that the decimal payload will be huge and it might overflow the input, i.e. url input on the browser, input-tag, form etc.

Friday, July 22, 2011

Song lyrics memorization using method of loci

Sometimes when studying to play a song on guitar or bass it's difficult enough to memorize chord changes, let alone singing along. This becomes more difficult if there are any syncopations or some rhythmic off-beat device in the song. In some songs some words in the whole chorus are different each time in a different bar, but you just can't manage to memorize which words belong to which repetition of the chorus. I propose a remedy for this problem.


First the muscle memory must already be familiar with the chord progressions, if you're compin' along to the melodies, the chords could be anchored to the lyrics and melody of the song.


Use the mnemonic device called the method of loci. The advantage of this method is that you can jump between from verse and chorus by just stepping into the room you've associated the verse or chorus with (in your mind).
Use real objects in the room, that are usually there, (e.g. tv, couch, rug in the living room, and toilet seat, shower in the bathroom) to anchor an initial strand of a story. The story is just a sequential translation of the lyrics into memorable narrative. The more outrageous, the more memorable.
If you speak multiple languages use translations of words and the phonetic information to link words together.



Manipulate the object translation of words in the lyrics in the space e.g. explosions, actions etc. Use a phonetic approximation of the word if it isn't an easily translatable object. It's important to anchor to existing objects in the space, e.g. tv, couch, toilet, showerhead, cupboard, dining table etc. One could also use synonyms but this would tend to require some thought (introduce a new layer of translation), which would take extra time.
If you speak multiple languages use translations of words and the phonetic information to link words together.

It's key to reduce the recall-time, to stay in the rhythm of the song, even before you actually need the information.
I discovered a trick to optimize on recall time, by grouping triggers together for the next word which fall on the start of the musical phrase, before you actually need the trigger. For example, you need to recall B in the following melodic phrase, you need A in the current melodic phrase, so you chunk mnemonic triggers for AB together, before you actually need B. You could also memorize a meta-trigger for B, instead of the real trigger for B.


It's important to walk through (in the mind) the rooms, during practice, as if you're walking through different parts of the song, so the sequence of the verse, bridge, chorus is easy to traverse. I use my friends homes to memorize songs.

For instance a pop song of 2 minutes, there would be at most 3 distinct lyrical parts e.g. verse, chorus, bridge. If certain parts occur together like two verses followed by a chorus, this could be chunked together in one room, then the rest could be chunked together in the following room; a song could theoretically require two rooms. Two songs could theoretically could fit into a locus of 5 rooms, mnemonically speaking.
You can also try to engage your limbic brain in memorizing the lyrics, by imagining the sensations produced by the lyrics. You can imagine feeling a warmth on your cheeks, when you sing the word "Hot" etc.

It's also good to use multiple non-conflicting triggers (e.g. sensations, images, narrative, onomotopeia, synonyms), in your story to encode the lyrics, eventually the strongest trigger will remain.

It's fairly obvious that one should also practice recalling the triggers.

Monday, March 14, 2011

Fun with a whiteboard

IT worker with a mind like water

Introduction

In this entry, I'll be proselytizing about my interpretation of Getting Things Done (GTD) by David Allen, mindfulness and my implementation of Agile principles.

All of this culminates in a project portfolio, for a high-level view of the project status.

Quick reference to GTD

GTD principles and mindfulness

In order to work at maximum efficiency in bursts during the day, one must maintain a mind which flows like water. IT-workers, like physical athletes, chess champions etc. must keep their cool and maintain a certain level-headedness to perform at the top of their game. An IT-worker can get to this state by practicing mindfulness excercises during down-time and implement GTD in their personal and professional lives.

Why GTD? Because it is a means to cast away projects and tasks and entrust them to a externalized system, so there would be no need to retain excess information in the mind. So your mind is free to react to or observe the situation. I'll write up a blog entry to illustrate some points made by cognitive studies which support the beneficial effects of the GTD system.

Why mindfulness? Because it's the new fad. No, not really, meditation has been with us for a long time, but meditation is only a means to an end.

Mindfulness can potentially relieve (not a 100% cure) certain physical manifestations of mental blockages (I'm not a dualist in the cartesian tradition). Like all other things in life, you need a time and a place to do this and practice. So that's taking care of the body/mind. Regular physical conditioning/exercise  is also a good idea. I won't cite the hundreds of research papers which confirm the relation between being mentally fit and physical exercise.

Meditating Lotus


A common goal mindfulness and GTD is to empty the mind of all baggage and to get in a relaxed control of the task at hand, with minimum interference from other senses. Even if you think it's all weird esoteric unscientific crap, there's always a possibility of a positive placebo effect on your mind. So try it.

David Allen also stresses the importance of setting positive goals. This creates a positive feedback loop, when things actually don't turn out like the worst-case scenario you initially envisioned.

Teams and Agile and GTD

I could imagine that the other team members might not fully appreciate your fascination with GTD or mindfulness. So lead by example.

So, how does one share a mind-like-water epiphenomenal state with your colleagues? Grab adhesive pieces of paper (e.g. stick-it), get a large sheet of paper or a whiteboard, start writing down all of the project details as a group. Group together similar tasks / details. Find a comfortable granularity i.e. level of description for the tasks for the whole team. Not too abstract and not too detailed. Unload your team's collective mind. This is a free-flowing brainstorm / brain unload state.  The unloading state can be done over a week or in 5 minutes. Depending on the size of the project. I personally did a drive-by braindump with my team once.

Braindump / fun with stick-its



The whiteboard


Get together with your team. Your role is to provide the constraints of the project. Per task, sort the precedence of certain tasks depending on the priority of the task. This is a filtering state. Make a plan in iterations for the coming x weeks. Every iteration should be no longer than 2 weeks. For every task, subproject, try to make a informed guess how long that task would take to accomplish. Also try to define the priority of that feature with the client and your teammates. It's important to make a clear seperation between the "unloading" state and the filtering / analytical / censor state.

If management insists on disrupting you or team members to do multi-project multi-tasking, use GTD on a lower-level for each disruptable team member. Use your project portfolio and project backlog to defend your team member, against unwelcome intrusions like these, for example make your point clear to "intruders" that your project has no time to spare etc. In any case a project portfolio is a common base you can use to negotiate, within the team or with upper-management.

Spreadsheet based project portfolio, left: monthly plan, right: weekly plan.


Another method to maintain a team's commitment during a barrage of incidental crap, use a kanban to keep the focus on the project at hand. Also, use commitment and consistency. Let the person(s) who is or are going to be responsible for the task write down her name on the piece of paper.

Simple KanBan: wait, active, finished.


For software developers you might want to describe the following states on the kanban (per feature) for an iteration:
  1. Develop
  2. Test
  3. Refactor
  4. Merge
  5. Commit to version control
  6. Integration Test
  7. Deploy
Listen to your team members, to find the right kanban which works for everyone. Update the kanban when required.

Depending on the size of the team, do standups. Do project backlogs, so you can make a project portfolio, do a velocity charts. But in any case never plan alone, always use the data provided by the whole team.

My software idea

I envision a drag and drop interface to create an online kanban system, where states can be defined. Using xmpp and bosh to give project members updates in changes within the kanban system. Integration with XMPP-based chat systems. All of this integrated with a calendar (gcalendar?) and a GTD based system where tasks can be delegated to people and be inserted to the wait list or the calendar.  Ad hoc commands are in the protocol to deliver the data payload.

Conclusion

There is a common thread between agile and GTD. If you include team members and let them actively participate, you can leverage the group's wisdom to improve commitment to the project and also improve the way it is going to be developed. This is a way for your team to get into the zone.

Wednesday, December 15, 2010

Wat ik geleerd heb van het kopen van een pak

Introductie

Blijkbaar is het een ongeschreven regel dat men voor een solicitatiegesprek voor een management of leidinggevende positie in het algemeen, met een pak moet aankomen. Ik ga ervanuit dat de lezer, net zoals ik, graag herenpakken wil (gaan) dragen, dus ik schrijf deze blogpost niet vanuit het perspectief van de vrouw. Maar sommige principes die ik beschrijf zijn ook wel van toepassing op vrouwenpakken, denk ik.

Gij zult een corporate kostuum dragen voor een belangrijk gesprek. Ongeacht of die mooie trui waarmee jij wil verschijnen en een goede indruk wil wekken honderden euro's gekost heeft. Ongeacht of dat speciaal shirtje van je, je eerder geluk heeft mogen brengen, waardoor jij dat shirt al in jaren niet meer hebt gewassen... doe gewoon een pak aan. Zoals dat sentiment mooi verwoord wordt in de tv-serie, HIMYM (How I met your mother):







Basisstappen

Nee? Nog nooit een pak gekocht? Geen ramp. Let op de volgende zaken:
  • Bepaal ten eerste wat je maximaal wil gaan betalen, kortom bepaal je budget, als de euro geen zware inflatie ondergaat, dan zal 450 euro voldoen, incl. schoenen, overhemd en das);
  • Kijke, kijke, niet kope, zoek een aantal winkels op in de grote stad, wellicht ook in de buurt van jouw omgeving;
  • Bepaal bij de eerste zaak die je bezoek welke maat je hebt, door dat aan iemand te vragen, dit scheelt tijd namelijk, voor je volgende bezoeken;
  • Vraag om hulp, wees niet te trots om hulp te vragen, wees assertief, maar niet onbeschoft, jij bent de klant en de klant is koning, maar vraag expliciet aan de verkoper of hij zijn professionele advies wil geven, wanneer je merkt dat er te vaak ja wordt geknikt;
  • Bekijk verschillende pakken, let op bepaalde aspecten wat je wel of niet leuk vindt;
  • Vraag de hulpgevende winkelbediende (of hoe dat tegenwoordig heet), hoe lang verkoper werkzaam is in de kostuumbranche (herenmode branch);
  • Toets de kennis van de verkoper, bijv. vraag wat voor effect horizontale, diagonale, verticale lijnen heeft op de drager van een pak:
    • Horizontaal maakt dik (als je slankt bent);
    • Verticaal maakt lang;
    • Diagonaal voor het versterken van het contrast t.o.v. de reeds aanwezige lijnen. Je ziet doorgaands nooit pakken met diagonale strepen, dit wekt de indruk (vermoedelijk) dat je wankel bent, en scheef staat.
  • Als je een zaak binnenloopt, bepaal alvorens voor jezelf met welk doel je die pak gaat aantrekken, bij voorbeeld een blauw pak met verticale strepen, dus je lijkt langer en autoritair, in ieder geval, met die pak straal je zelfvertrouwen uit, vertel de verkoper welk doel jij beoogt;

Het beïnvloeden van je perceptie

Manchetknopen

Een competente verkoper zal je op vriendelijk en toeschietelijk wijze benaderen, die zal lachen om jouw grapjes (stel dat je ze maakt). Je zult die persoon wellicht mogen. Wanneer een potentiële koper een verkoper mag, dan wordt er een weg gebaand voor wederkerigheid. Kortom, de verkoper is aardig tegen me, dus ik zal als koper-zijnde zal je belonen d.m.v. de aankoop op deze pak en talloze dure acessoires. Mensen zijn eerder geneigd om zich te associeren met mensen die zij uit een positieve ervaring kennen, waardoor een koper eerder geneigd om dezelfde aankoop op dezelfde plaats te doen.

Let op de invloed van perceptuele contrast, d.w.z., wanneer je veel dure dingen om je heen hebt, dan zullen andere dure kleine artikelen (relatief t.o.v. andere winkels) alleen normaal geprijsd lijken, bijv. je wordt omringd door pakken van duizenden euro's, (die je uiteraard, niet allemaal moet gaan kopen) dan lijkt een paar sokken van 25 euro normaal. Terwijl je misschien bij de hema voor dat bedrag 50 van dezelfde paar sokken kan kopen, als het ware. Kortom, besteed geen geld aan de acessoires die relatief normaal afgeprijsd lijken. Koop die horloge, overhemd, dassen, schoenen, sokken, manchetknopen elders als je geld wilt besparen. In dit geval is het contrast normaliserend.

Perceptuele contrast geldt ook voor hebbedingetjes die in de aanbieding zijn, let op de prijzen van alle artikelen in de winkel. Is alles boven 500 euro en hoger?  Is die paar sokken afgeprijsd van 75 naar 25 euro? Voor paar sokken... wauw, dat lijkt goedkoop. Hier is het contrast versterkend.

Het is verstandig om te bepalen welke winkels goedkoop zijn en welke duur zijn. De aanname, dat goedkoop is duurkoop of dat duur impliceert goede kwaliteit, gaat niet atijd op, wees daar bewust van. Het gaat om de perceptie van de mensen die de pak waarnemen. Als je zegt dat iets duur is, (zonder dat dit werkelijk duizenden euro's gekost heeft), als men die perceptie al hebben, dan is dat ook zo in hun verbeelding. De reden waarom grote bedrijven die pakken verkopen, mega-winst kunnen maken is omdat zij het hele productieproces uitbesteden aan lage-lonen landen. De werkelijke waarde is een optelsom van de materiaalkosten plus productieloonkosten plus vervoerkosten plus verkoperskosten, denk aan provisie voor elk pak voor de verkoper en zijn uurloon. Ik heb geen concrete cijfers gezien, maar ik heb zo'n flauw vermoeden.

Stel dat de pak die je wilt nog enigzins bijgesneden moet worden of op één of een andere manier bewerkt moet worden en je hebt nog niet definitief besloten dat je de pak wil aanschaffen. Een effectieve verkoper zal jou proberen te beïnvloeden, d.m.v. de schaarsheid principe.  Bijvoorbeeld, stel dat je heel snel binnenkort een pak nodig hebt, dit heb je per ongeluk verteld aan de verkoper. De verkoper zal je aan herinneren dat jouw pak (ongeacht welke pak dat moge zijn) wel 4 à 6 weken zou gaan duren om te maken, om je ook indirect te herinneren aan gemiste mogelijke kansen in het verschiet. Het effect van deze herinnering is dat je een enorme aandrang zult voelen om die betreffende pak meteen aan te schaffen. Mensen raken in het algemeen sneller in paniek wanneer zij geloven dat zij dingen zullen mislopen in de toekomst, waardoor zij de helderheid verliezen om verstandige besluiten te nemen.
Afgezien van de schaarste in de tijd, kunnen verkopers producten ook schaars laten lijken. Denk aan zeldzaam geziene pakken die gemaakt zijn door een of een andere belangrijke ontwerper die niet zoveel pakken maakt.

Een wat oudere (uitziende) verkoper, of een verkoper die meent dat hij al langer in het vak zit, zal mogelijk erop aandringen dat je zijn advies moet nemen en vele autoriteitsargumenten geven, zoals: "Uit ervaring heb ik geleerd dat bladibladibla.". Je brein vertelt je dat deze persoon is een autoriteit, je brein zegt: "...dus ik moet wel zijn advies volgen, anders is dat ten nadele van mij, die niet zoveel weet hierover...".

Een goede verkoper zal veel voorstellen doen wat betreft acessoires, opties, combinaties etc. De verkoper zal je veel dingen laten aanraken.  Zij weten echter dat wanneer verkoopartikelen eenmaal aangeraakt worden door een potentiële koper, dan zal dat artikel met een grotere kans gekocht worden door de (hand)tastelijke koper. Ik vermoed dat dit te maken heeft met de commitment en consistentie principes. Wanneer de commitment voor het kopen van een artikel reeds vaag aanwezig is, zal de commitment hieraan versterkt worden door een positieve tastzintuigelijke waarneming, waardoor het consistentie gedeelte van de beïnvloeding zal zegevieren over de rede, (heb ik deze prullaria wel nodig?), kortom, je brein zegt: "oe leuk, koop die hap!".


Contrast

Vermijd cognitieve dissonanties, geen vloekende kleuren (bijv. laat iemand die niet kleurenblind is je ensemble'tje nakijken). Sluit belachelijke contrasten uit, bijv. hele donkere sokken bij een witte broek, behalve als je moet moonwalken als Michael Jackson. De waarnemer van je pak, bij degene waar de coginitieve dissonantie ontstaat, zal bewust of onbewust een oordeel vormen over jouw hele persoon op basis van deze schijnlijke bedrieglijke onbelangrijke "foutje". Wellicht is de perceptie van de waarnemer van jou in één woord samen te vatten: slordig.

Wat ik nog niet genoemd heb is social proof en conformity, vrij vertaald, sociale bewijsvoering en conformiteit, dit is wanneer een groep verkopers menen dat een bepaald voorwerp je mooi staat, bijv. een duur acessoire bij je dure pak, terwijl jij dat ding zelf bij voorbaat afschuwelijk vindt. Er ontstaat een grote aandrang om te conformeren aan de verwachting van die groep, ik kan me voorstellen dat de volgende gedachtes door je hoofd gaat: "Er zijn zoveel mensen die hetzelfde denken, ik zal wel gek zijn. Ik zal het maar moeten kopen."

Deze psychologische beïnvloedingstactieken zoals liking (iemand mogen, vriendelijk zijn), autoriteit, perceptuele contrast,  schaarsheid, wederkerigheid, commitment en consistentie, sociale bewijsvoering en conformiteit zijn ook van toepassing op andere branches. Denk aan een mooie auto die bij je pak past in de autoverkoopbranche. Dat artikel schrijf ik later wel als ik zelf hoger ben opgeklommen en een auto nodig heb.

Onderhandeling

Een beetje ervaren verkoper zal je gelijk een derde oor proberen aan te naaien, maar trap er niet in! Ga in discussie, neem vooraf onderzoek naar prijzen van pakken en gebruik deze feiten die je oppikt tijdens de onderhandeling over de prijs. Maak aantekeningen als je geen goed geheugen hebt. Neem desnoods foto's, maar vraag eerst om de toestemming van de zaak.

Val de verkoper aan op prijs, gebruik wat je weet over de objectieve gemiddelde prijs, maar wees geduldig en beleefd voor de andere onderhandelende partij.

Bijvoorbeeld, zeg dat je twee dassen wil met die pak, all-in. Want dat scheelt jullie twee de moeite. Het scheelt de verkoper de moeite om een nieuwe sukkel te vinden. Voor jouw scheelt het de moeite om die dassen elders vinden. Probeer anders af te dingen, je zegt bijv. "okee, één das dan...". Probeer wederzijdse concessies te maken.

Stel dat je onderhandeling mislukt, je zult die das niet zomaar krijgen met die pak, all-in, want blijkbaar is de prijs echte heel scherp (o, echt waar?), we hebben nog altijd het internet. Bovendien, er is slechts één maat voor alle dassen. Tijdens de onderhandeling, probeer te benadrukken dat jij onderhandelt vanuit het algemene belang, dat je uitgaat van een win-win situatie. Zeg dat je binnenkort (half jaar?) ook voor andere festiviteiten een pak nodig hebt, wat verdomd veel lijkt op een lange-termijn relatie lijkt tussen jou en verkoper.

Conclusie

Een pak kopen vereist voorbereiding. Om te voorkomen dat je te veel betaalt voor iets moet je bewust omgaan met bepaalde beïnvloedingen om je heen.

Links & Bronnen

What I learned from a headhunter for a managerial job opening

First of all, I am an unofficial student of dr. Robert Cialdini's work, with regard to his published work on influence. Since I read and reread his seminal work, the world started to make sense, I started to understand on a deeper level, why people did certain things in a certain way. Especially people who wanted you to be compliant to their way of thinking or commit to their cause and be consistent about it too.

When dealing with these types of people, for instance this headhunter I met, he started with authority, i.e. "We are among the top three headhunters in the world, we have 600-700 shops around the world". This might not be true, but it's damn impressive nonetheless.

Then he proceeded with scarcity, i.e. "We only handle cases starting from 45k euro per annum otherwise it isn't interesting for us; when we request an interview with someone we mean business, we know who are the best", in my opinion the last is also meant to flatter the interviewee, which is liking and still a hint of authority, e.g. "We only interview the best" or some variation of that.

I think this is standard stuff for headhunters.

Suppose that you botch up the interview, by not being completely awake, because you couldn't sleep, with all the excitement bubbling inside of you because you have an interview the following day for a very special position (read: ka-ching). Anyway, you realize half-way you're not getting the job (right now), because you're not doing too well selling yourself, with buzz-words and short soundbites to describe your professional skills and experience, so you start to actually relax and do quite well, because you start to act as yourself and let your guard down.

In this case, apply active listening (from dr. Thomas Gordon), so the interviewer will tell you more than (s)he is actually allowed to tell you. Like the name of the company, so you can skip over the headhunter and go for the company yourself and negotiate.
I don't recommend screwing over headhunters, because they are also human and fallible, but if they start getting sloppy, they should learn like all human beings, e.g. by error, pain etc.

Get a suit for the interview


Okay, the things I learned actually can be summarized in bullets:
  • Watch your body language, give an impression with your body that you're comfortable with talking about yourself and you're enthusiastic about the job prospect;
  • Familiarize yourself with real names of positions you would like to attain further on the (cannibalistic corporate canine-trophic) ladder;
  • If you come from academia or your family and friends tend to talk on an abstract level, please leave the academic at home, be concrete, do not hide behind abstractions as a protection mechanism (i.e. a way to stay safe from a barrage of prying questions);
  • Wear a suit and proportional management shoes for management positions, comb your hair;
  • Wrap around stories based on certain keywords that are related to this position, e.g. I worked day and night on blabla, above and beyond..., (so you're dedicated); I negotiated hard on blabla, (so you're assertive...);
  • Tell something about yourself with interview power words and emotive stories;
  • Apply influence, make the stories believable and compelling, so they end up with the same conclusion or lead them to the same conclusion. Also use the interviewer's name when giving examples;
  • Do not be self-deprecative, do not slag off your previous employer(s), just say you reached a certain level of growth in your profession, you want to excel beyond this level (mind you, excel is a power word);
  • Oh, don't make shit up, they will find out. (I didn't, because I assume this is common sense and eventually you'll probably end up getting black-mailed.);
  • Make sure your references back you up, because don't underestimate the power of social proof.
  • Practice your pitch with an unbiased observer!
Good luck with the job hunt.

Tuesday, October 12, 2010

mutt smtp server support (no local mta)

Suppose you want to use a text-based mail client without having to install and setup a full-fledged mail-transfer agent (mta). Mutt from version 1.5 on, has support for your smtp
server (internet mta) on the internet.

All you need to do is recompile with the extra option --enable-smtp in ./configure.

See the last line of the following command:

# ...
./configure \
  --prefix=/usr \
  --mandir=/usr/man \
  --sysconfdir=/etc/mutt \
  --with-mailpath=/var/spool/mail \
  --enable-pop \
  --enable-imap \
  --with-ssl \
  --enable-locales-fix \
  --without-wc-funcs \
  --build=$ARCH-slackware-linux \
  --enable-smtp # <-- add this extra argument!
# ...
To configure the server you need to create a file called .muttrc in your $HOME and enter the following settings:
#openssl aes-256-cbc -in test.txt -out test.txt.enc # encrypt
#openssl enc -d -aes-256-cbc -in test.txt.enc       # decrypt
#echo "body" | mutt -s "subject" -F muttrc addressee@somewhere.com -a attachment
set smtp_url="smtp://smtp.server.tld"
set realname="Mutt Forevah"
set from="Who-ay-Em Ayemhoo"

Adapt to your smtp server settings accordingly.