Yes your intuition is correct. It has something to do with する.
- される is the passive verb form of する.
What does the passive-form do?
AはBをぶつ - "A hits B"
AはBにぶたれる - "A gets hit by B" (The verb ぶつ is in the passive-construction)
Now why is it
され and not
され is the
連用形 of the passive construction of the verb
する for which auxiliaries such as
~ます etc. may be appended to
Let's examine what
~そう is an auxiliary construction that presents what the verb is expressing as a conjecture of the speaker concerning a present state or a future event based on the speaker's observation.
雨が降る "It is raining"
雨が降りそうです "It looks like it will rain"
Now we're left with combining
~になる "to become~" in past tense;
~になった "became ~", to form the expression
~そうになった which is roughly means:
Literally: became the state of "appearing to be ~"
Natural Translation: almost/nearly did ~
The next step is putting all the parts together step by step:
暴行する - "to assault"
暴行される - "to get assaulted"
暴行されそうです - "looks like will get (or is being) assaulted"
暴行されそうになった - "became the state of "looks like will get (or is being) assaulted" "
Then we try to naturally understand the last step and end up with:
"to almost get assaulted"
暴行されそうになった is followed by
ところを (which I imagine is derived from ところ + を + Elided Verb) (I'm not really sure where
ところを comes from and also deriving it would be out of the scope of this question)
ところを means something like "in the midst of" and is quite similar to
ときに (Their difference would also be out of the scope of this question)
暴行されそうになったところを would roughly mean "In the midst of almost getting assaulted"