This is a contentious question and has been much debated even from the time of Origen. According to Origen, the account of Michael disputing with Satan over the body of Moses, is attributed to material contained in the Testament of Moses [also known as, "The Apocalypse of Moses", or, "The Assumption of Moses"]. However, about one third of the text of the Testament of Moses is now missing and there is no mention of such an incident in the text that remains.
Modern critical scholarship (with which I only rarely agree) suggest that this part of Jude is a midrash of Zech 3 and material from the Testament of Moses [eg, https://en.wikipedia.org/wiki/Assumption_of_Moses ]. Certainly, Jude quotes often from both the OT pseudepigrapha, eg, Jude 14, 15 quotes 1 Enoch 1:9.
The idea of the LORD rebuking people is a regular theme in the OT, for example:
- Ps 18:15 - The channels of the sea appeared, and the foundations of the world were exposed, at Your rebuke, O LORD, at the blast of the breath of Your nostrils.
- 1 Sam 22:16 - The channels of the sea appeared, and the foundations of the world were exposed at the rebuke of the LORD, at the blast of the breath of His nostrils.
- Prov 3:11 - My son, do not reject the discipline of the LORD, and do not loathe His rebuke;
- Isa 51:20 - Your sons have fainted; they lie at the head of every street, like an antelope in a net. They are full of the wrath of the LORD, the rebuke of your God.
However, none of these has the LORD rebuking the devil/Satan, so the verbal parallels between Jude and Zech 3 are strong, especially when we include the phrase "snatching from the fire". However, in the latter case, Zech 3:2 is discussing Jerusalem while Jude 23 is discussing the remnant of the faithful.
Further, two different people are involved: Joshua (the priest in Zech 3) and Moses (the prophet in Jude). Further, different people are speaking: the LORD speaks in Zech 3:2 and Michael speaks in Jude 9.
Lastly, if we grant that Jude 9 is alluding to Zech 3:2, we have gained little because Zech 3:2 throws no light in Jude.
I think it is safest to conclude that "the LORD rebukes" was a common Hebrew idiom used by Jude to recount what happened at the death of Moses. On this basis, Zech 3:2 might be using the idiom from the story of Moses; ... but we cannot know for certain.