Yes your intuition is correct. It has something to do with する.
- される is the passive verb form of する.
What does the passive-form do?
Compare:
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 連用形+そう does:
~そう 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.
Compare:
雨が降る "It is raining"
雨が降りそうです "It looks like it will rain"
Now we're left with combining そう with ~になる "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"
Now 暴行されそうになった 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)
Their combination, 暴行されそうになったところを would roughly mean "In the midst of almost getting assaulted"