Can I join the Dark Brotherhood after I got attacked by one of their Assassins?
No. What you've encountered is a Dark Brotherhood Assassin. These can randomly appear and attack you before you've joined the Dark Brotherhood. To finally join the Brotherhood you will have to complete the quest "With Friends Like These...".
To get this quest you will have to sleep in a bed after you've finished "Innocence Lost". You can still join the Brotherhood despite being attacked by one of their assassins.
The only thing that really prevents you from joining the Brotherhood apart from cheating is the quest "Destroy the Dark Brotherhood!". This can be triggered if you Kill Astrid instead of one of the three targets in "With Friends Like These...".
I was attacked by 3+ asassins from the Dark Brotherhood. Yet I still have managed to join, so yes, you can join after being attacked because the attacks are random.
- Complete Innocence Lost (talk to Aventus Aretino in Windhelm, kill Grelod the Kind, talk to Aventus again...)
- Wait for a courier to bring you a note with a black handprint and "we know" on it. If this does not happen, proceed to 3.
- Sleep in a bed, and wait to be abducted. You'll know what I mean when you get there. Good luck!