When someone files for bankruptcy, you file a short form called a "claim" in their bankruptcy estate stating what the debtor owes you and the nature of the debt by a deadline you should be given notice of, unless it is a "no asset" bankruptcy in which there are no funds after payments of secured debts and setting aside exempt property, in which you get nothing unless you are a secured debtor. Most bankruptcies are "no asset" chapter 7 bankruptcies.
Sometimes payment is made only out of the debtor's non-exempt assets and equity in the debtor's assets subject to security interests such as mortgages and car loans. Sometimes the debtor also has to make payments to the trustee for 3-5 years in Chapters 7 (liquidation), 11 (business reorganization), 12 (farm bankruptcies) or 13 (wage earners plans), that are distributed to creditors in proportion to their rights in the bankruptcy estate.
In general, the first debts to be paid in bankruptcy are secured debts (i.e. debts secured by specific collateral like a mortgage). The rights you have in the collateral will survive the bankruptcy even if there are no funds left over (although the amount of the debt is sometimes "crammed down" to the value of the asset serving as collateral if the collateral is worth less than the debt, this is only possible for certain kinds of secured debts, however). Creditors with collateral, however, need permission from the bankruptcy court to actually foreclose on the collateral in most cases. There are exceptions which are rather complicated when this can be done without bankruptcy court approval, but usually the general rule will apply. When you have rights as a secured creditor that survive bankruptcy, they can only be asserted by foreclosing the collateral, not through a personal money judgment against the bankrupt debtor.
Then, assets that are exempt from creditors remain property of the debtor and are not used to pay outstanding debts (e.g. a homestead exemption or an exception for tools of a trade or health care aids). The exemptions that are available vary from state to state.
Then, certain "priority debts" are paid, including claims to property held as a fiduciary for another. There are quite a few of these. If there are insufficient funds to pay priority debts (and there are lots of sub-priorities) the higher priority debts get paid and the lower priority debts don't, and when there are funds to pay only a part of the debts of a specific priority after paying off secured creditors and higher priority debts, the debts of that priority get paid cents on the dollar based upon what is left to pay them with after paying everyone else. The first priority debt is for expenses of administration of the estate (e.g. the bankruptcy trustee's fees and carrying costs incurred to preserve assets).
An list of the most common priority debts that might come up in consumer bankruptcies include:
wages, salaries, and commissions owed by an employer up to $13,650 per person earned within 180 days of your bankruptcy filing;
contributions to your employees’ benefit plans rendered within 180 days of your bankruptcy filing up to $13,650;
debts of up to $6,725 owed to certain farmers and fishermen;
up to $3,025 in deposits made for the purchase, lease, or rental of property or services for personal, family, or household use that were not delivered or provided;
alimony, maintenance, or support;
income taxes that became due within the three-year period before the bankruptcy filing date and taxes that were collected or withheld from an employee (trust fund taxes);
customs, duties, and penalties owing to federal, state, and local governmental units; and
claims for death or personal injury (not property damage) that came about because of your driving under the influence of alcohol or drugs.
Then, general creditors are paid at cents on the dollar if there is anything left after secured creditors and priority debts are paid in full. You would be a general creditor as to all debts except the mortgage and possibly your right to what is left of the probate estate assets. A written loan document does not prevent a debt from being a claim owed to a general creditor. Usually, a written loan document is a claim of a general creditor and comes behind secured debts, exempt property and all priority claims.
Also, certain debts (not necessarily priority debts) are not dischargeable in bankruptcy, but in most cases only if a timely adversary proceeding is brought in the bankruptcy to have them classified. Basically, these involve debts for breach of fiduciary duty and intentional frauds and torts and crimes, as well as alimony, child support, and student loans.
So, in general, one way to protect yourself is to get collateral for your debts or to get paid before the bankruptcy filing happens.
But, payments and collateral you get on the eve of bankruptcy (90 days prior to filing for outsiders, 1 year prior to filing for insiders like you) can be "clawed back" into the bankruptcy estate (subject to certain conditions) by the bankruptcy trustee to the extent that you end up getting more than you would have if you did nothing and took your share in the bankruptcy estate.
This greatly limits what you can do on the eve of bankruptcy to protect yourself, especially for significant debt payments that the trustee would bother trying to claw back.
Also, the S-corporation may or may not file for bankruptcy itself. If you are owed a debt by the S-corporation rather than your brother individually, and the S-corporation doesn't file for bankruptcy (even if your brother owns the company), your debt is not part of the bankruptcy. You can't know in advance whether the S-corporation will file for bankruptcy.
The probate estate is not allowed to file for bankruptcy, however.
Likewise, a debt owed by the probate estate is either a priority claim or not subject to the bankruptcy at all.
But, if you brother has misappropriated assets from the probate estate that as a result are no longer available as probate estate assets, those won't be recoverable from him because they are debts for a breach of fiduciary duty or theft, rather than assets of the probate estate, unless an adversary action is commenced in a timely fashion (the deadline is short and almost impossible to extend) to classify those debts as non-dischargeable.
On the other hand, the probate estate can make distributions that reflect amounts he has already received in what is called a "set off" of his right to receive an inheritance v. debts he owes to the probate estate. Set offs have the same priority as security interests, although it may be necessary to seek permission from the bankruptcy estate to take them.
It is conceivable that a setoff might be available in the case of the real property investment, but that is less obvious and fact specific.
One thing that you probably can do without it constituting a preference is to get your brother to agree in writing regarding what he owns as a factual matter. This will reduce litigation in the bankruptcy court.
Another thing you can do is have him turn over responsibility for being executor of the probate estate to you, if he will agree to do so.
Another thing you can do is to trade something that your brother has that has non-economic sentimental value to you, for the fair market value (substantially equivalent value is one of the terms of art used), in a contemporaneous deal so that the sentimental thing isn't tied up in the bankruptcy and potentially sold to pay creditors.
Almost all of your debts except the mortgage will probably be erased in bankruptcy and there is little you can do about it, but you will probably get your fair share of the probate estate while your brother gets what is left over.